Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
require './my_cache_store'
class MyCacheStoreWithTimeExpiry < MyCacheStore
attr_reader :options
def initialize(options = {})
super()
@refresh_in = options.fetch(:refresh_in) { Float::INFINITY }
end
def write(key, value)
@store_hash[key.to_sym] = { value: value, created_at: Time.now }
end
def read(key)
value_hash = @store_hash[key.to_sym]
return nil unless value_hash
if Time.now - value_hash[:created_at] > @refresh_in
nil
else
value_hash[:value]
end
end
end