Add cache key prefix in cached collection repository

This commit is contained in:
Thibaud Fabre
2016-01-20 15:19:05 +01:00
parent 5cc19d2e97
commit dd1ad99f7f
3 changed files with 25 additions and 15 deletions

View File

@@ -56,7 +56,7 @@ final class CachedCollectionRepository implements CollectionRepository
*/
public function findAll()
{
$cacheKey = hash('sha256', $this->cacheKey);
$cacheKey = $this->getCacheKey();
/** @var \collection[] $collections */
$collections = $this->cache->fetch($cacheKey);
@@ -91,7 +91,7 @@ final class CachedCollectionRepository implements CollectionRepository
{
$this->repository->save($collection);
$cacheKey = hash('sha256', $this->cacheKey);
$cacheKey = $this->getCacheKey();
$this->cache->delete($cacheKey);
}
@@ -100,7 +100,7 @@ final class CachedCollectionRepository implements CollectionRepository
{
$this->repository->delete($collection);
$cacheKey = hash('sha256', $this->cacheKey);
$cacheKey = $this->getCacheKey();
$this->cache->delete($cacheKey);
}
@@ -109,4 +109,14 @@ final class CachedCollectionRepository implements CollectionRepository
{
$this->cache->save($key, $value);
}
/**
* @return string
*/
private function getCacheKey()
{
$cacheKey = 'collections:' . hash('sha256', $this->cacheKey);
return $cacheKey;
}
}