Explicitly flush isolated caches by key for content updates (#20519)
* Explicitly flush isolated caches by key for content updates * Apply suggestions from code review --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -1378,6 +1378,11 @@ public class DocumentRepository : ContentRepositoryBase<int, IContent, DocumentR
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
|
||||
// We need to flush the isolated cache by key explicitly here.
|
||||
// The ContentCacheRefresher does the same thing, but by the time it's invoked, custom notification handlers
|
||||
// might have already consumed the cached version (which at this point is the previous version).
|
||||
IsolatedCache.ClearByKey(RepositoryCacheKeys.GetKey<IContent, Guid>(entity.Key));
|
||||
|
||||
// troubleshooting
|
||||
//if (Database.ExecuteScalar<int>($"SELECT COUNT(*) FROM {Constants.DatabaseSchema.Tables.DocumentVersion} JOIN {Constants.DatabaseSchema.Tables.ContentVersion} ON {Constants.DatabaseSchema.Tables.DocumentVersion}.id={Constants.DatabaseSchema.Tables.ContentVersion}.id WHERE published=1 AND nodeId=" + content.Id) > 1)
|
||||
//{
|
||||
|
||||
@@ -541,6 +541,11 @@ public class MediaRepository : ContentRepositoryBase<int, IMedia, MediaRepositor
|
||||
OnUowRefreshedEntity(new MediaRefreshNotification(entity, new EventMessages()));
|
||||
|
||||
entity.ResetDirtyProperties();
|
||||
|
||||
// We need to flush the isolated cache by key explicitly here.
|
||||
// The MediaCacheRefresher does the same thing, but by the time it's invoked, custom notification handlers
|
||||
// might have already consumed the cached version (which at this point is the previous version).
|
||||
IsolatedCache.ClearByKey(RepositoryCacheKeys.GetKey<IMedia, Guid>(entity.Key));
|
||||
}
|
||||
|
||||
protected override void PersistDeletedItem(IMedia entity)
|
||||
|
||||
Reference in New Issue
Block a user