Class: Geocoder::CacheStore::Redis
- Defined in:
- lib/geocoder/cache_stores/redis.rb
Instance Method Summary collapse
-
#initialize(store, options) ⇒ Redis
constructor
A new instance of Redis.
- #keys ⇒ Object
- #read(url) ⇒ Object
- #remove(key) ⇒ Object
- #write(url, value, expire = @expiration) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(store, options) ⇒ Redis
Returns a new instance of Redis.
5 6 7 8 |
# File 'lib/geocoder/cache_stores/redis.rb', line 5 def initialize(store, ) super @expiration = [:expiration] end |
Instance Method Details
#keys ⇒ Object
22 23 24 |
# File 'lib/geocoder/cache_stores/redis.rb', line 22 def keys store.keys("#{prefix}*") end |
#read(url) ⇒ Object
18 19 20 |
# File 'lib/geocoder/cache_stores/redis.rb', line 18 def read(url) store.get key_for(url) end |
#remove(key) ⇒ Object
26 27 28 |
# File 'lib/geocoder/cache_stores/redis.rb', line 26 def remove(key) store.del(key) end |
#write(url, value, expire = @expiration) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/geocoder/cache_stores/redis.rb', line 10 def write(url, value, expire = @expiration) if expire.present? store.set key_for(url), value, ex: expire else store.set key_for(url), value end end |