Sha256: ed345ebf905af25f9af1a0c728291667c38b34a845b087741f5329ef539b6665

Contents?: true

Size: 818 Bytes

Versions: 26

Compression:

Stored size: 818 Bytes

Contents

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

module Moneta
  class Redis
    include Defaults
    
    def initialize(options = {})
      @cache = ::Redis.new(options)
    end
    
    def key?(key)
      !@cache[key].nil?
    end
    
    alias has_key? key?
    
    def [](key)
      @cache.get(key)
    end
    
    def []=(key, value)
      store(key, value)
    end
        
    def delete(key)
      value = @cache[key]
      @cache.delete(key) if value
      value
    end
    
    def store(key, value, options = {})
      @cache.set(key, value, options[:expires_in])
    end
    
    def update_key(key, options = {})
      val = @cache[key]
      self.store(key, val, options)
    end
    
    def clear
      @cache.flush_db
    end
  end
end

Version data entries

26 entries across 26 versions & 9 rubygems

Version Path
aeden-moneta-0.6.2 lib/moneta/redis.rb
aeden-moneta-0.6.3 lib/moneta/redis.rb
benschwarz-moneta-0.6.1 lib/moneta/redis.rb
benschwarz-smoke-0.5.0 vendor/moneta/lib/moneta/redis.rb
benschwarz-smoke-0.5.1 vendor/moneta/lib/moneta/redis.rb
benschwarz-smoke-0.5.2 vendor/moneta/lib/moneta/redis.rb
benschwarz-smoke-0.5.3 vendor/moneta/lib/moneta/redis.rb
benschwarz-smoke-0.5.4 vendor/moneta/lib/moneta/redis.rb
benschwarz-smoke-0.5.5 vendor/moneta/lib/moneta/redis.rb
benschwarz-smoke-0.5.6 vendor/moneta/lib/moneta/redis.rb
jferris-moneta-0.6.2 lib/moneta/redis.rb
jsl-moneta-0.6.1 lib/moneta/redis.rb
jsl-moneta-0.6.2 lib/moneta/redis.rb
jsl-moneta-0.6.3 lib/moneta/redis.rb
smurphy-moneta-0.6.0 lib/moneta/redis.rb
birdgrinder-0.1.5 lib/moneta/redis.rb
birdgrinder-0.1.4.0 lib/moneta/redis.rb
birdgrinder-0.1.3.1 lib/moneta/redis.rb
birdgrinder-0.1.3.0 lib/moneta/redis.rb
birdgrinder-0.1.2.1 lib/moneta/redis.rb