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
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