class Rack::Cache::EntityStore
Entity stores are used to cache response bodies across requests. All Implementations are required to calculate a SHA checksum of the data written which becomes the response body's key.
Constants
- DISK
Stores entity bodies on disk at the specified path.
- FILE
Stores entity bodies on disk at the specified path.
- GAE
- GAECACHE
- HEAP
Stores entity bodies on the heap using a Hash object.
- MEM
Stores entity bodies on the heap using a Hash object.
- MEMCACHE
- MEMCACHED
Private Instance Methods
bytesize(string)
click to toggle source
# File lib/rack/cache/entitystore.rb, line 26 def bytesize(string); string.bytesize; end
slurp(body) { |part| ... }
click to toggle source
Read body calculating the SHA1 checksum and size while yielding each chunk to the block. If the body responds to close, call it after iteration is complete. Return a two-tuple of the form: [ hexdigest, size ].
# File lib/rack/cache/entitystore.rb, line 14 def slurp(body) digest, size = Digest::SHA1.new, 0 body.each do |part| size += bytesize(part) digest << part yield part end body.close if body.respond_to? :close [digest.hexdigest, size] end