Class: Rack::Cache::MetaStore::Heap
Overview
Concrete MetaStore implementation that uses a simple Hash to store request/response pairs on the heap.
Constant Summary
DISK, FILE, GAE, GAECACHE, HEAP, MEM, MEMCACHE, MEMCACHED
Class Method Summary
collapse
Instance Method Summary
collapse
#cache_key, #invalidate, #lookup, #store
Constructor Details
#initialize(hash = {}, options = {}) ⇒ Heap
Returns a new instance of Heap.
201
202
203
204
|
# File 'lib/rack/cache/meta_store.rb', line 201
def initialize(hash={}, options = {})
@hash = hash
@options = options
end
|
Class Method Details
.resolve(uri, options = {}) ⇒ Object
227
228
229
|
# File 'lib/rack/cache/meta_store.rb', line 227
def self.resolve(uri, options = {})
new({}, options)
end
|
Instance Method Details
#purge(key) ⇒ Object
218
219
220
221
|
# File 'lib/rack/cache/meta_store.rb', line 218
def purge(key)
@hash.delete(key)
nil
end
|
#read(key) ⇒ Object
206
207
208
209
210
211
212
|
# File 'lib/rack/cache/meta_store.rb', line 206
def read(key)
if data = @hash[key]
Marshal.load(data)
else
[]
end
end
|
#to_hash ⇒ Object
223
224
225
|
# File 'lib/rack/cache/meta_store.rb', line 223
def to_hash
@hash
end
|
#write(key, entries, ttl = nil) ⇒ Object
214
215
216
|
# File 'lib/rack/cache/meta_store.rb', line 214
def write(key, entries, ttl = nil)
@hash[key] = Marshal.dump(entries)
end
|