class Moneta::Redis

Public Class Methods

new(options = {}) click to toggle source
# File lib/moneta/redis.rb, line 12
def initialize(options = {})
  @cache = ::Redis.new(options)
end

Public Instance Methods

[](key) click to toggle source
# File lib/moneta/redis.rb, line 22
def [](key)
  @cache.get(key)
end
[]=(key, value) click to toggle source
# File lib/moneta/redis.rb, line 26
def []=(key, value)
  store(key, value)
end
clear() click to toggle source
# File lib/moneta/redis.rb, line 45
def clear
  @cache.flush_db
end
delete(key) click to toggle source
# File lib/moneta/redis.rb, line 30
def delete(key)
  value = @cache[key]
  @cache.delete(key) if value
  value
end
has_key?(key)
Alias for: key?
key?(key) click to toggle source
# File lib/moneta/redis.rb, line 16
def key?(key)
  !@cache[key].nil?
end
Also aliased as: has_key?
store(key, value, options = {}) click to toggle source
# File lib/moneta/redis.rb, line 36
def store(key, value, options = {})
  @cache.set(key, value, options[:expires_in])
end
update_key(key, options = {}) click to toggle source
# File lib/moneta/redis.rb, line 40
def update_key(key, options = {})
  val = @cache[key]
  self.store(key, val, options)
end