module Moneta::Expires

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/moneta.rb, line 15
def [](key)
  check_expired(key)
  super
end
check_expired(key) click to toggle source
# File lib/moneta.rb, line 3
def check_expired(key)
  if @expiration[key] && Time.now > @expiration[key]
    @expiration.delete(key)
    self.delete(key)
  end
end
delete(key) click to toggle source
Calls superclass method
# File lib/moneta.rb, line 25
def delete(key)
  check_expired(key)
  super
end
fetch(key, default = nil, &blk) click to toggle source
Calls superclass method
# File lib/moneta.rb, line 20
def fetch(key, default = nil, &blk)
  check_expired(key)
  super
end
key?(key) click to toggle source
Calls superclass method
# File lib/moneta.rb, line 10
def key?(key)
  check_expired(key)
  super
end
store(key, value, options = {}) click to toggle source
Calls superclass method
# File lib/moneta.rb, line 34
def store(key, value, options = {})
  ret = super(key, value)
  update_options(key, options)
  ret
end
update_key(key, options) click to toggle source
# File lib/moneta.rb, line 30
def update_key(key, options)
  update_options(key, options)
end

Private Instance Methods

update_options(key, options) click to toggle source
# File lib/moneta.rb, line 41
def update_options(key, options)
  if options[:expires_in]
    @expiration[key] = (Time.now + options[:expires_in])
  end
end