Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
module ActiveSupport
module Cache
class MemoryStoreWithExpiry < MemoryStore
def initialize
super
@times = {}
end
def write(name, value, options = nil)
if options && options[:expires_in]
@times[name] = { :cached_at => Time.now, :expires_in => options[:expires_in] }
end
super
end
def read(name, options = nil)
return if expired?(name)
super
end
private
def expired?(name)
return false unless @times[name]
(Time.now - @times[name][:cached_at]) > @times[name][:expires_in]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.