V15: Fix reload memory cache endpoint (#17446)

* Check for id later.

* Return 501 status codes from obsoleted endpoints

* Use contants

* Ensure ordering of cache refresher is not changes

---------

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Nikolaj Geisle
2024-11-07 13:17:36 +01:00
committed by GitHub
parent e7eb14d310
commit d101829a90
3 changed files with 18 additions and 14 deletions

View File

@@ -86,15 +86,16 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
var idsRemoved = new HashSet<int>();
IAppPolicyCache isolatedCache = AppCaches.IsolatedCaches.GetOrCreate<IContent>();
foreach (JsonPayload payload in payloads.Where(x => x.Id != default))
foreach (JsonPayload payload in payloads)
{
// By INT Id
isolatedCache.Clear(RepositoryCacheKeys.GetKey<IContent, int>(payload.Id));
// By GUID Key
isolatedCache.Clear(RepositoryCacheKeys.GetKey<IContent, Guid?>(payload.Key));
if (payload.Id != default)
{
// By INT Id
isolatedCache.Clear(RepositoryCacheKeys.GetKey<IContent, int>(payload.Id));
// By GUID Key
isolatedCache.Clear(RepositoryCacheKeys.GetKey<IContent, Guid?>(payload.Key));
}
// remove those that are in the branch
if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.RefreshBranch | TreeChangeTypes.Remove))
@@ -115,7 +116,10 @@ public sealed class ContentCacheRefresher : PayloadCacheRefresherBase<ContentCac
HandleNavigation(payload);
HandlePublishedAsync(payload, CancellationToken.None).GetAwaiter().GetResult();
_idKeyMap.ClearCache(payload.Id);
if (payload.Id != default)
{
_idKeyMap.ClearCache(payload.Id);
}
if (payload.Key.HasValue)
{
_idKeyMap.ClearCache(payload.Key.Value);