@api public
# File lib/rack/cache/moneta.rb, line 65 def initialize(cache) @cache = cache end
# File lib/rack/cache/moneta.rb, line 74 def exist?(key) @cache.key?(key) end
# File lib/rack/cache/moneta.rb, line 69 def open(key) data = read(key) data && [data] end
# File lib/rack/cache/moneta.rb, line 89 def purge(key) @cache.delete(key) nil end
# File lib/rack/cache/moneta.rb, line 78 def read(key) @cache[key] end
# File lib/rack/cache/moneta.rb, line 82 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