Sha256: f617319bc47064f4fd9307d8c8e446e9b389de2c68d9ea753e5f50651123c8b9

Contents?: true

Size: 721 Bytes

Versions: 13

Compression:

Stored size: 721 Bytes

Contents

begin
  require "redis"
rescue LoadError
  puts "You need the redis gem to use the Redis store"
  exit
end

module Moneta
  module Adapters
    class Redis
      include Defaults

      def initialize(options = {})
        @cache = ::Redis.new(options)
      end

      def key?(key, *)
        !@cache[key_for(key)].nil?
      end

      def [](key)
        deserialize(@cache.get(key_for(key)))
      end

      def delete(key, *)
        string_key = key_for(key)
        value = self[key]
        @cache.del(string_key) if value
        value
      end

      def store(key, value, *)
        @cache.set(key_for(key), serialize(value))
      end

      def clear(*)
        @cache.flushdb
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
moneta-splattael-0.7.0 lib/moneta/adapters/redis.rb
dkastner-moneta-1.2.0 lib/moneta/adapters/redis.rb
dkastner-moneta-1.1.1 lib/moneta/adapters/redis.rb
dkastner-moneta-1.1.0 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.6 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.5 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.4 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.3 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.2 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.1 lib/moneta/adapters/redis.rb
dkastner-moneta-1.0.0 lib/moneta/adapters/redis.rb
dkastner-moneta-0.7.0 lib/moneta/adapters/redis.rb
thoughtless-moneta-0.6.0.2 lib/moneta/adapters/redis.rb