[HttpKernel] made the cache key generation configurable for the default HttpCache store

This commit is contained in:
Fabien Potencier 2013-09-27 17:45:20 +02:00
parent 9f35ca5ea1
commit 780b77af58

View File

@ -364,6 +364,25 @@ class Store implements StoreInterface
return $this->root.DIRECTORY_SEPARATOR.substr($key, 0, 2).DIRECTORY_SEPARATOR.substr($key, 2, 2).DIRECTORY_SEPARATOR.substr($key, 4, 2).DIRECTORY_SEPARATOR.substr($key, 6);
}
/**
* Generates a cache key for the given Request.
*
* This method should return a key that must only depend on a
* normalized version of the request URI.
*
* If the same URI can have more than one representation, based on some
* headers, use a Vary header to indicate them, and each representation will
* be stored independently under the same cache key.
*
* @param Request $request A Request instance
*
* @return string A key for the given Request
*/
protected function generateCacheKey(Request $request)
{
return 'md'.hash('sha256', $request->getUri());
}
/**
* Returns a cache key for the given Request.
*
@ -377,7 +396,7 @@ class Store implements StoreInterface
return $this->keyCache[$request];
}
return $this->keyCache[$request] = 'md'.hash('sha256', $request->getUri());
return $this->keyCache[$request] = $this->generateCacheKey($request);
}
/**