Sha256: ae1f425b063e976eb062e2deddfe2c5cad7eec613ad226053dcb61bd35523e0b
Contents?: true
Size: 602 Bytes
Versions: 7
Compression:
Stored size: 602 Bytes
Contents
# This class implements a cache with simple delegation to the Redis store, but # when it creates a key/value pair, it also sends an EXPIRE command with a TTL. # It should be fairly simple to do the same thing with Memcached. class AutoexpireCacheRedis def initialize(store, ttl = 86400) @store = store @ttl = ttl end def [](url) @store.get(url) end def []=(url, value) @store.set(url, value) @store.expire(url, @ttl) end def keys @store.keys end def del(url) @store.del(url) end end Geocoder.configure(:cache => AutoexpireCacheRedis.new(Redis.new))
Version data entries
7 entries across 7 versions & 2 rubygems