aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2024-03-04 12:29:55 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-03-08 08:51:08 +0000
commit0d0855b596d249667c6d1ecc1ed76e6f40c49919 (patch)
treeed9c5e876311216e554107faacb7d7c71912ec9e /lib
parent89b8f86eec1cd16ee7368a191454a45bb034cc34 (diff)
downloadnextcloud-server-0d0855b596d249667c6d1ecc1ed76e6f40c49919.tar.gz
nextcloud-server-0d0855b596d249667c6d1ecc1ed76e6f40c49919.zip
fix: Avoid clear cache with prefix
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Collaboration/Reference/ReferenceManager.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Collaboration/Reference/ReferenceManager.php b/lib/private/Collaboration/Reference/ReferenceManager.php
index 1db87a56494..a837651f1fe 100644
--- a/lib/private/Collaboration/Reference/ReferenceManager.php
+++ b/lib/private/Collaboration/Reference/ReferenceManager.php
@@ -117,6 +117,11 @@ class ReferenceManager implements IReferenceManager {
$reference = $matchedProvider->resolveReference($referenceId);
if ($reference) {
+ $cachePrefix = $matchedProvider->getCachePrefix($referenceId);
+ if ($cachePrefix !== '') {
+ // If a prefix is used we set an additional key to know when we need to delete by prefix during invalidateCache()
+ $this->cache->set('hasPrefix-' . md5($cachePrefix), true, self::CACHE_TTL);
+ }
$this->cache->set($cacheKey, Reference::toCache($reference), self::CACHE_TTL);
return $reference;
}
@@ -161,7 +166,11 @@ class ReferenceManager implements IReferenceManager {
*/
public function invalidateCache(string $cachePrefix, ?string $cacheKey = null): void {
if ($cacheKey === null) {
- $this->cache->clear(md5($cachePrefix));
+ // clear might be a heavy operation, so we only do it if there have actually been keys set
+ if ($this->cache->remove('hasPrefix-' . md5($cachePrefix))) {
+ $this->cache->clear(md5($cachePrefix));
+ }
+
return;
}