Class | Rack::Cache::EntityStore::Heap |
In: |
lib/rack/cache/entitystore.rb
|
Parent: | EntityStore |
Stores entity bodies on the heap using a Hash object.
Create the store with the specified backing Hash.
# File lib/rack/cache/entitystore.rb, line 38 38: def initialize(hash={}) 39: @hash = hash 40: end
Determine whether the response body with the specified key (SHA1) exists in the store.
# File lib/rack/cache/entitystore.rb, line 44 44: def exist?(key) 45: @hash.include?(key) 46: end
Remove the body corresponding to key; return nil.
# File lib/rack/cache/entitystore.rb, line 69 69: def purge(key) 70: @hash.delete(key) 71: nil 72: end
Read all data associated with the given key and return as a single String.
# File lib/rack/cache/entitystore.rb, line 56 56: def read(key) 57: (body = @hash[key]) && body.join 58: end