mirror of
https://github.com/nextcloud/server.git
synced 2026-03-13 22:22:25 -04:00
Merge pull request #44077 from nextcloud/backport/43992/stable25
[stable25] fix: Avoid clear cache with prefix
This commit is contained in:
commit
5426fd6a65
1 changed files with 10 additions and 1 deletions
|
|
@ -99,6 +99,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;
|
||||
}
|
||||
|
|
@ -131,7 +136,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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue