fix DB collection cache (#4130)

This commit is contained in:
Aina Sitraka
2022-09-13 19:05:46 +03:00
committed by GitHub
parent a3f811546f
commit df9642ed2f
4 changed files with 19 additions and 4 deletions

View File

@@ -74,4 +74,10 @@ class ArrayCacheCollectionRepository implements CollectionRepository
unset($this->collectionCache[$collection->getCollectionId()]); unset($this->collectionCache[$collection->getCollectionId()]);
} }
} }
public function clearCache()
{
$this->collectionCache = null;
$this->collectionRepository->clearCache();
}
} }

View File

@@ -91,15 +91,18 @@ final class CachedCollectionRepository implements CollectionRepository
{ {
$this->repository->save($collection); $this->repository->save($collection);
$cacheKey = $this->getCacheKey(); $this->clearCache();
$this->cache->delete($cacheKey);
} }
public function delete(Collection $collection) public function delete(Collection $collection)
{ {
$this->repository->delete($collection); $this->repository->delete($collection);
$this->clearCache();
}
public function clearCache()
{
$cacheKey = $this->getCacheKey(); $cacheKey = $this->getCacheKey();
$this->cache->delete($cacheKey); $this->cache->delete($cacheKey);

View File

@@ -597,6 +597,9 @@ class collection implements ThumbnailedElement, cache_cacheableInterface
$this->getReferenceRepository()->save($this->reference); $this->getReferenceRepository()->save($this->reference);
$this->collectionRepositoryRegistry->purgeRegistry(); $this->collectionRepositoryRegistry->purgeRegistry();
// clear cached collection
$this->getCollectionRepository()->clearCache();
// clear the trivial cache of databox->get_collections() // clear the trivial cache of databox->get_collections()
$this->get_databox()->clearCache(databox::CACHE_COLLECTIONS); $this->get_databox()->clearCache(databox::CACHE_COLLECTIONS);
@@ -617,6 +620,9 @@ class collection implements ThumbnailedElement, cache_cacheableInterface
$this->getReferenceRepository()->save($this->reference); $this->getReferenceRepository()->save($this->reference);
$this->collectionRepositoryRegistry->purgeRegistry(); $this->collectionRepositoryRegistry->purgeRegistry();
// clear cached collection
$this->getCollectionRepository()->clearCache();
// clear the trivial cache of databox->get_collections() // clear the trivial cache of databox->get_collections()
$this->get_databox()->clearCache(databox::CACHE_COLLECTIONS); $this->get_databox()->clearCache(databox::CACHE_COLLECTIONS);

View File

@@ -198,7 +198,7 @@
<li> <li>
<form class='form-inline' method="post" action="{{ path('admin_collection_enable', {'bas_id': baseId}) }}"> <form class='form-inline' method="post" action="{{ path('admin_collection_enable', {'bas_id': baseId}) }}">
{{ baseId|bas_labels(app) }} {{ baseId|bas_labels(app) }}
<a href="#" class="btn btn-mini reload submiter">{{ "Activer" | trans }}></a> <a href="#" class="btn btn-mini reload submiter">{{ "Activer" | trans }}</a>
</form> </form>
</li> </li>
{% endfor %} {% endfor %}