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

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

Constant Summary

Constants inherited from Rack::Client::Cache::MetaStore

HEAP, MEM

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rack::Client::Cache::MetaStore

#cache_key, #lookup, #persist_request, #persist_response, #requests_match?, #restore_response, #store

Constructor Details

#initialize(hash = {}) ⇒ Heap

Returns a new instance of Heap.



99
100
101
# File 'lib/rack/client/middleware/cache/metastore.rb', line 99

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

Class Method Details

.resolve(uri) ⇒ Object



122
123
124
# File 'lib/rack/client/middleware/cache/metastore.rb', line 122

def self.resolve(uri)
  new
end

Instance Method Details

#purge(key) ⇒ Object



113
114
115
116
# File 'lib/rack/client/middleware/cache/metastore.rb', line 113

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

#read(key) ⇒ Object



103
104
105
106
107
# File 'lib/rack/client/middleware/cache/metastore.rb', line 103

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

#to_hashObject



118
119
120
# File 'lib/rack/client/middleware/cache/metastore.rb', line 118

def to_hash
  @hash
end

#write(key, entries) ⇒ Object



109
110
111
# File 'lib/rack/client/middleware/cache/metastore.rb', line 109

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