Sha256: a77982d0f134f46aeffc8219ab5c7a51806cf4ad42d4ae950756429d60d67fe1
Contents?: true
Size: 601 Bytes
Versions: 2
Compression:
Stored size: 601 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.[](url) end def []=(url, value) @store.[]=(url, value) @store.expire(url, @ttl) end def keys @store.keys end def del(url) @store.del(url) end end Geocoder2.configure(:cache => AutoexpireCacheRedis.new(Redis.new))
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geocoder2-0.1.1 | examples/autoexpire_cache_redis.rb |
geocoder2-0.1.0 | examples/autoexpire_cache_redis.rb |