aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-03-08 09:37:36 +0100
committerGitHub <noreply@github.com>2024-03-08 09:37:36 +0100
commitb6691b35c7be946f038a6c8c6d221e64c60788f4 (patch)
tree3f965162af665a7de17e1e6d40a1518181f60395
parent34069087df0087a7b4e93161da288ac2f07c5ea2 (diff)
parent972a611288b941fe5b01555e3e965a4e098d24aa (diff)
downloadnextcloud-server-b6691b35c7be946f038a6c8c6d221e64c60788f4.tar.gz
nextcloud-server-b6691b35c7be946f038a6c8c6d221e64c60788f4.zip
Merge pull request #43992 from nextcloud/fix/avoid-cache-clear
fix: Avoid clear cache with prefix
-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;
}