Sha256: 8499c8d82d6855bcd404e9485f998f657c890d215ed2deb72de2576d88497684

Contents?: true

Size: 942 Bytes

Versions: 7

Compression:

Stored size: 942 Bytes

Contents

module Rack
  module Cache
    class MetaStore
      class RedisBase < MetaStore
        extend Rack::Utils

        # The ::MarshaledRedis object used to communicate with the Redis daemon.
        attr_reader :cache

        def self.resolve(uri)
          db = uri.path.sub(/^\//, '')
          db = "0" if db.empty?
          server = { :host => uri.host, :port => uri.port || "6379", :db => db }
          new server
        end
      end

      class Redis < RedisBase
        def initialize(server, options = {})
          @cache = ::MarshaledRedis.new server
        end

        def read(key)
          key = hexdigest(key)
          cache.marshalled_get(key) || []
        end

        def write(key, entries)
          key = hexdigest(key)
          cache.marshalled_set(key, entries)
        end

        def purge(key)
          cache.del(hexdigest(key))
          nil
        end
      end

      REDIS = Redis
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
honkster-redis-store-0.3.16 lib/rack/cache/redis_metastore.rb
honkster-redis-store-0.3.15 lib/rack/cache/redis_metastore.rb
honkster-redis-store-0.3.14 lib/rack/cache/redis_metastore.rb
honkster-redis-store-0.3.13 lib/rack/cache/redis_metastore.rb
honkster-redis-store-0.3.12 lib/rack/cache/redis_metastore.rb
honkster-redis-store-0.3.11 lib/rack/cache/redis_metastore.rb
honkster-redis-store-0.3.10 lib/rack/cache/redis_metastore.rb