Sha256: 215ce2d0696eb0676fe7db7f3eb0f05fd2d84286d13df23f91e1ed3582b5d3a1

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 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.get(key) || []
        end

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

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

      REDIS = Redis
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dsander-redis-store-0.3.8 lib/rack/cache/redis_metastore.rb