Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Avoid clear cache with prefix
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and backportbot[bot] committed Mar 8, 2024
commit 2160260285aab953e19f1f6770c575bdcd17c972
11 changes: 10 additions & 1 deletion lib/private/Collaboration/Reference/ReferenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public function resolveReference(string $referenceId): ?IReference {

$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;
}
Expand Down Expand Up @@ -190,7 +195,11 @@ private function getFullCacheKey(IReferenceProvider $provider, string $reference
*/
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;
}

Expand Down