Sha256: cf0d6509c1246b7b3bc52ef8db8dc188d54346d4bdcaeafd9ee18476abb07f0f

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

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

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

        def self.resolve(uri)
          new ::Redis::Factory.convert_to_redis_client_options(uri.to_s)
        end
      end

      class Redis < RedisBase
        def initialize(server, options = {})
          options[:redis_server] ||= server
          @cache = ::Redis::Factory.create options
        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

3 entries across 3 versions & 2 rubygems

Version Path
instructure-redis-store-1.0.0.2.instructure1 lib/rack/cache/redis_metastore.rb
instructure-redis-store-1.0.0.1.instructure1 lib/rack/cache/redis_metastore.rb
redis-store-1.0.0.1 lib/rack/cache/redis_metastore.rb