summaryrefslogtreecommitdiffstats
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:41:02 +0000
commit29511d85f3dd2e266a4c427a18866c3af36cd729 (patch)
tree785af124dfa1edc7e4c115b063407a9d7eea8130 /lib
parent355bc5e18de0a470db3c7002fcb8d71a8026fa69 (diff)
downloadnextcloud-server-29511d85f3dd2e266a4c427a18866c3af36cd729.tar.gz
nextcloud-server-29511d85f3dd2e266a4c427a18866c3af36cd729.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 2897410f5d6..96730583bd2 100644
--- a/lib/private/Collaboration/Reference/ReferenceManager.php
+++ b/lib/private/Collaboration/Reference/ReferenceManager.php
@@ -137,6 +137,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;
}
@@ -190,7 +195,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;
}