aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2024-03-04 12:29:55 +0100
committerJoas Schilling <coding@schilljs.com>2024-03-08 09:08:43 +0100
commit972a611288b941fe5b01555e3e965a4e098d24aa (patch)
tree3f965162af665a7de17e1e6d40a1518181f60395 /lib
parent34069087df0087a7b4e93161da288ac2f07c5ea2 (diff)
downloadnextcloud-server-972a611288b941fe5b01555e3e965a4e098d24aa.tar.gz
nextcloud-server-972a611288b941fe5b01555e3e965a4e098d24aa.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;
}