Sha256: 82902e3947352dd5ce6ae50b4a72dcc325af51e13b3fb702ae0686d2eb5cd717

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

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

        # The Redis::MarshaledClient 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 = ::Redis::MarshaledClient.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

4 entries across 4 versions & 1 rubygems

Version Path
redis-store-0.3.9 lib/rack/cache/redis_metastore.rb
redis-store-1.0.0.beta2 lib/rack/cache/redis_metastore.rb
redis-store-1.0.0.beta1 lib/rack/cache/redis_metastore.rb
redis-store-0.3.8 lib/rack/cache/redis_metastore.rb