Object
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.
# File lib/rack/cache/entitystore.rb, line 28 28: def bytesize(string); string.size; end
# File lib/rack/cache/entitystore.rb, line 26 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 14: def slurp(body) 15: digest, size = Digest::SHA1.new, 0 16: body.each do |part| 17: size += bytesize(part) 18: digest << part 19: yield part 20: end 21: body.close if body.respond_to? :close 22: [digest.hexdigest, size] 23: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.