Added HttpCache\Store::generateContentDigest() + changed visibility

This commit is contained in:
Jérôme Vieilledent 2012-11-14 23:35:13 +01:00 committed by Fabien Potencier
parent 2d488b79f2
commit d2920c94a1

View File

@ -24,7 +24,7 @@ use Symfony\Component\HttpFoundation\Response;
*/
class Store implements StoreInterface
{
private $root;
protected $root;
private $keyCache;
private $locks;
@ -154,7 +154,7 @@ class Store implements StoreInterface
// write the response body to the entity store if this is the original response
if (!$response->headers->has('X-Content-Digest')) {
$digest = 'en'.sha1($response->getContent());
$digest = $this->generateContentDigest($response);
if (false === $this->save($digest, $response->getContent())) {
throw new \RuntimeException('Unable to store the entity.');
@ -192,6 +192,18 @@ class Store implements StoreInterface
return $key;
}
/**
* Returns content digest for $response.
*
* @param Response $response
*
* @return string
*/
protected function generateContentDigest(Response $response)
{
return 'en'.sha1($response->getContent());
}
/**
* Invalidates all cache entries that match the request.
*