Add cache busting via save method of collection repository

This commit is contained in:
Thibaud Fabre
2015-07-09 19:00:34 +02:00
parent 977e778b61
commit c5cab178a9
5 changed files with 63 additions and 14 deletions

View File

@@ -55,7 +55,7 @@ final class CachedCollectionRepository implements CollectionRepository
*/
public function findAll()
{
$cacheKey = hash('sha256', $this->cacheKey . '.findAll');
$cacheKey = hash('sha256', $this->cacheKey);
/** @var \collection[] $collections */
$collections = $this->cache->fetch($cacheKey);
@@ -86,6 +86,15 @@ final class CachedCollectionRepository implements CollectionRepository
return null;
}
public function save(\collection $collection)
{
$this->repository->save($collection);
$cacheKey = hash('sha256', $this->cacheKey);
$this->cache->delete($cacheKey);
}
private function putInCache($key, $value)
{
$this->cache->save($key, $value);