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.
Stores entity bodies on disk at the specified path.
Stores entity bodies on disk at the specified path.
Stores entity bodies on the heap using a Hash object.
Stores entity bodies on the heap using a Hash object.
# File lib/rack/cache/entitystore.rb, line 26 def bytesize(string); string.bytesize; end
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