/usr/lib/ruby/1.8/moneta.rb is in libmoneta-ruby1.8 0.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | module Moneta
module Expires
def check_expired(key)
if @expiration[key] && Time.now > @expiration[key]
@expiration.delete(key)
self.delete(key)
end
end
def key?(key)
check_expired(key)
super
end
def [](key)
check_expired(key)
super
end
def fetch(key, default = nil, &blk)
check_expired(key)
super
end
def delete(key)
check_expired(key)
super
end
def update_key(key, options)
update_options(key, options)
end
def store(key, value, options = {})
ret = super(key, value)
update_options(key, options)
ret
end
private
def update_options(key, options)
if options[:expires_in]
@expiration[key] = (Time.now + options[:expires_in])
end
end
end
module StringExpires
include Expires
def check_expired(key)
if @expiration[key] && Time.now > Time.at(@expiration[key].to_i)
@expiration.delete(key)
delete(key)
end
end
private
def update_options(key, options)
if options[:expires_in]
@expiration[key] = (Time.now + options[:expires_in]).to_i.to_s
end
end
end
module Defaults
def fetch(key, value = nil)
value ||= block_given? ? yield(key) : default
self[key] || value
end
def store(key, value, options = {})
self[key] = value
end
end
end
|