class Rack::Cache::EntityStore::MONETA
@api public
Public Class Methods
new(cache)
click to toggle source
# File lib/rack/cache/moneta.rb, line 67 def initialize(cache) @cache = cache end
Public Instance Methods
exist?(key)
click to toggle source
# File lib/rack/cache/moneta.rb, line 76 def exist?(key) @cache.key?(key) end
open(key)
click to toggle source
# File lib/rack/cache/moneta.rb, line 71 def open(key) data = read(key) data && [data] end
purge(key)
click to toggle source
# File lib/rack/cache/moneta.rb, line 91 def purge(key) @cache.delete(key) nil end
read(key)
click to toggle source
# File lib/rack/cache/moneta.rb, line 80 def read(key) @cache[key] end
write(body, ttl = 0)
click to toggle source
# File lib/rack/cache/moneta.rb, line 84 def write(body, ttl = 0) buf = StringIO.new key, size = slurp(body) { |part| buf.write(part) } @cache.store(key, buf.string, ttl == 0 ? {} : { expires: ttl }) [key, size] end