diff --git a/README.md b/README.md index 9c4883a22b7474313f7d6a4f3e91615bac40d171..79f9299a0ce8c107fcda419e6123986d4f45a819 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/lib/geocoder/cache.rb b/lib/geocoder/cache.rb index fe2794db48f25805de64ebc681d506c1103670a7..defb256125f614bb798c8e638aaae7e416b01f19 100644 --- a/lib/geocoder/cache.rb +++ b/lib/geocoder/cache.rb @@ -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