Sha256: b6c91ac9d5d17c4abc72355d56bacffaa499dafa0e1e779760c96089b86dbc0a

Contents?: true

Size: 570 Bytes

Versions: 62

Compression:

Stored size: 570 Bytes

Contents

# from Geocoder GitHub Repository
#
# 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.
#
module Workarea
  class AutoexpireCacheRedis
    def initialize(store, ttl = 259200) # "time to live" of 3 days
      @store = store
      @ttl = ttl
    end

    def [](url)
      @store.get(url)
    end

    def []=(url, value)
      @store.setex(url, @ttl, value)
    end

    def keys
      @store.keys
    end

    def del(url)
      @store.del(url)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.26 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.45 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.25 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.23 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.44 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.22 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.43 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.21 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.42 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.20 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.41 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.19 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.40 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.18 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.39 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.17 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.38 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.5.16 lib/workarea/autoexpire_cache_redis.rb
workarea-core-3.4.37 lib/workarea/autoexpire_cache_redis.rb