class Rack::Cache::MetaStore::HEAP
Concrete MetaStore implementation that uses a simple Hash to store request/response pairs on the heap.
Public Class Methods
new(hash={}, options = {})
click to toggle source
# File lib/rack/cache/meta_store.rb, line 202 def initialize(hash={}, options = {}) @hash = hash @options = options end
resolve(uri, options = {})
click to toggle source
# File lib/rack/cache/meta_store.rb, line 228 def self.resolve(uri, options = {}) new({}, options) end
Public Instance Methods
purge(key)
click to toggle source
# File lib/rack/cache/meta_store.rb, line 219 def purge(key) @hash.delete(key) nil end
read(key)
click to toggle source
# File lib/rack/cache/meta_store.rb, line 207 def read(key) if data = @hash[key] Marshal.load(data) else [] end end
to_hash()
click to toggle source
# File lib/rack/cache/meta_store.rb, line 224 def to_hash @hash end
write(key, entries, ttl = nil)
click to toggle source
# File lib/rack/cache/meta_store.rb, line 215 def write(key, entries, ttl = nil) @hash[key] = Marshal.dump(entries) end