Class: Rack::Cache::MetaStore::Heap

Inherits:
Rack::Cache::MetaStore show all
Defined in:
lib/rack/cache/metastore.rb

Overview

Concrete MetaStore implementation that uses a simple Hash to store request/response pairs on the heap.

Constant Summary

Constants inherited from Rack::Cache::MetaStore

DISK, FILE, GAE, GAECACHE, HEAP, MEM, MEMCACHE, MEMCACHED

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rack::Cache::MetaStore

#cache_key, #invalidate, #lookup, #store

Constructor Details

#initialize(hash = {}) ⇒ Heap

Returns a new instance of Heap.


173
174
175
# File 'lib/rack/cache/metastore.rb', line 173

def initialize(hash={})
  @hash = hash
end

Class Method Details

.resolve(uri) ⇒ Object


196
197
198
# File 'lib/rack/cache/metastore.rb', line 196

def self.resolve(uri)
  new
end

Instance Method Details

#purge(key) ⇒ Object


187
188
189
190
# File 'lib/rack/cache/metastore.rb', line 187

def purge(key)
  @hash.delete(key)
  nil
end

#read(key) ⇒ Object


177
178
179
180
181
# File 'lib/rack/cache/metastore.rb', line 177

def read(key)
  @hash.fetch(key, []).collect do |req,res|
    [req.dup, res.dup]
  end
end

#to_hashObject


192
193
194
# File 'lib/rack/cache/metastore.rb', line 192

def to_hash
  @hash
end

#write(key, entries) ⇒ Object


183
184
185
# File 'lib/rack/cache/metastore.rb', line 183

def write(key, entries)
  @hash[key] = entries
end