class Ro::Cache

Public Instance Methods

invalidate(key) click to toggle source
# File lib/ro/cache.rb, line 21
def invalidate(key)
  prefix = Array(key).dup.tap{|array| array.pop}
  set(prefix, {})
end
read(key, &block) click to toggle source
# File lib/ro/cache.rb, line 8
def read(key, &block)
  if has?(key)
    get(key)
  else
    if block
      value = block.call
      write(key, value)
    else
      nil
    end
  end
end
write(key, value) click to toggle source
# File lib/ro/cache.rb, line 3
def write(key, value)
  invalidate(key)
  set(key => value)
end