Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
28 lines (23 sloc) 428 Bytes
class MyCacheStore
attr_accessor :store_hash
def initialize
@store_hash = {}
end
def write(key, value)
@store_hash[key.to_sym] = value
end
def read(key)
@store_hash[key.to_sym]
end
def fetch(key)
raise('Block should be provided') unless block_given?
result = read(key)
if result.nil?
result = yield
write(key, result)
result
else
result
end
end
end
You can’t perform that action at this time.