public override void Refresh(JsonPayload[] payloads) { // we need to clear the ContentType runtime cache since that is what caches the // db data type to store the value against and anytime a datatype changes, this also might change // we basically need to clear all sorts of runtime caches here because so many things depend upon a data type ClearAllIsolatedCacheByEntityType <IContent>(); ClearAllIsolatedCacheByEntityType <IContentType>(); ClearAllIsolatedCacheByEntityType <IMedia>(); ClearAllIsolatedCacheByEntityType <IMediaType>(); ClearAllIsolatedCacheByEntityType <IMember>(); ClearAllIsolatedCacheByEntityType <IMemberType>(); Attempt <IAppPolicyCache?> dataTypeCache = AppCaches.IsolatedCaches.Get <IDataType>(); foreach (JsonPayload payload in payloads) { _idKeyMap.ClearCache(payload.Id); if (dataTypeCache.Success) { dataTypeCache.Result?.Clear(RepositoryCacheKeys.GetKey <IDataType, int>(payload.Id)); } } // TODO: not sure I like these? TagsValueConverter.ClearCaches(); SliderValueConverter.ClearCaches(); // refresh the models and cache _publishedModelFactory.WithSafeLiveFactoryReset(() => _publishedSnapshotService.Notify(payloads)); base.Refresh(payloads); }
public override void Refresh(JsonPayload[] payloads) { // TODO: refactor // we should NOT directly clear caches here, but instead ask whatever class // is managing the cache to please clear that cache properly _contentTypeCommonRepository.ClearCache(); // always if (payloads.Any(x => x.ItemType == typeof(IContentType).Name)) { ClearAllIsolatedCacheByEntityType <IContent>(); ClearAllIsolatedCacheByEntityType <IContentType>(); } if (payloads.Any(x => x.ItemType == typeof(IMediaType).Name)) { ClearAllIsolatedCacheByEntityType <IMedia>(); ClearAllIsolatedCacheByEntityType <IMediaType>(); } if (payloads.Any(x => x.ItemType == typeof(IMemberType).Name)) { ClearAllIsolatedCacheByEntityType <IMember>(); ClearAllIsolatedCacheByEntityType <IMemberType>(); } foreach (var id in payloads.Select(x => x.Id)) { _idKeyMap.ClearCache(id); } if (payloads.Any(x => x.ItemType == typeof(IContentType).Name)) { // don't try to be clever - refresh all ContentCacheRefresher.RefreshContentTypes(AppCaches); } if (payloads.Any(x => x.ItemType == typeof(IMediaType).Name)) { // don't try to be clever - refresh all MediaCacheRefresher.RefreshMediaTypes(AppCaches); } if (payloads.Any(x => x.ItemType == typeof(IMemberType).Name)) { // don't try to be clever - refresh all MemberCacheRefresher.RefreshMemberTypes(AppCaches); } // refresh the models and cache _publishedModelFactory.WithSafeLiveFactoryReset(() => _publishedSnapshotService.Notify(payloads)); // now we can trigger the event base.Refresh(payloads); }