Class: Geocoder::CacheStore::Redis

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/cache_stores/redis.rb

Instance Method Summary collapse

Methods inherited from Base

#urls

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, options)
  super
  @expiration = options[:expiration]
end

Instance Method Details

#keysObject



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