Skip to content
Snippets Groups Projects
Commit 4427ebf0 authored by ttilberg's avatar ttilberg Committed by Alex Reisner
Browse files

Update docs, error msg for cache store #keys (#1165)

parent 2921ed13
No related branches found
No related tags found
No related merge requests found
......@@ -896,6 +896,7 @@ This example uses Redis, but the cache store can be any object that supports the
* `store#[](key)` or `#get` or `#read` - retrieves a value
* `store#[]=(key, value)` or `#set` or `#write` - stores a value
* `store#del(url)` - deletes a value
* `store#keys` - (Optional) Returns array of keys. Used if you wish to expire the entire cache (see below).
Even a plain Ruby hash will work, though it's not a great choice (cleared out when app is restarted, not shared between app instances, etc).
......
......@@ -40,7 +40,11 @@ module Geocoder
#
def expire(url)
if url == :all
urls.each{ |u| expire(u) }
if store.respond_to?(:keys)
urls.each{ |u| expire(u) }
else
raise(NoMethodError, "The Geocoder cache store must implement `#keys` for `expire(:all)` to work")
end
else
expire_single_url(url)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment