Load Balancing: Clear request cache in cache version accessor on cache version update to prevent unnecessary cache roll forwards (#20831)

* Clear request cache on version update

* Update src/Umbraco.Core/Cache/IRepositoryCacheVersionAccessor.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Mole
2025-11-14 14:14:28 +01:00
committed by GitHub
parent 342cb171eb
commit 2a609e1eca
3 changed files with 22 additions and 2 deletions

View File

@@ -77,5 +77,17 @@ public class RepositoryCacheVersionAccessor : IRepositoryCacheVersionAccessor
return databaseVersion;
}
/// <inheritdoc />
public void VersionChanged(string cacheKey)
{
var removed = _requestCache.Remove(cacheKey);
if (removed is false)
{
_logger.LogDebug("Cache version for key {CacheKey} wasn't removed from request cache, possibly missing HTTP context", cacheKey);
}
}
/// <inheritdoc />
public void CachesSynced() => _requestCache.ClearOfType<RepositoryCacheVersion>();
}