public override void Refresh(string json) { var payloads = Deserialize(json); foreach (var payload in payloads) { foreach (var alias in GetCacheKeysForAlias(payload.Alias)) { CacheHelper.RuntimeCache.ClearCacheByKeySearch(alias); } var macroRepoCache = CacheHelper.IsolatedRuntimeCache.GetCache <IMacro>(); if (macroRepoCache) { macroRepoCache.Result.ClearCacheItem(RepositoryCacheKeys.GetKey <IMacro>(payload.Id)); } } ; base.Refresh(json); }
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>(); var dataTypeCache = AppCaches.IsolatedCaches.Get <IDataType>(); foreach (var 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) { AppCaches.RuntimeCache.ClearOfType <PublicAccessEntry>(); var idsRemoved = new HashSet <int>(); var isolatedCache = AppCaches.IsolatedCaches.GetOrCreate <IContent>(); foreach (var payload in payloads) { isolatedCache.Clear(RepositoryCacheKeys.GetKey <IContent>(payload.Id)); _idkMap.ClearCache(payload.Id); // remove those that are in the branch if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.RefreshBranch | TreeChangeTypes.Remove)) { var pathid = "," + payload.Id + ","; isolatedCache.ClearOfType <IContent>((k, v) => v.Path.Contains(pathid)); } //if the item is being completely removed, we need to refresh the domains cache if any domain was assigned to the content if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.Remove)) { idsRemoved.Add(payload.Id); } } if (idsRemoved.Count > 0) { var assignedDomains = _domainService.GetAll(true).Where(x => x.RootContentId.HasValue && idsRemoved.Contains(x.RootContentId.Value)).ToList(); if (assignedDomains.Count > 0) { // TODO: this is duplicating the logic in DomainCacheRefresher BUT we cannot inject that into this because it it not registered explicitly in the container, // and we cannot inject the CacheRefresherCollection since that would be a circular reference, so what is the best way to call directly in to the // DomainCacheRefresher? ClearAllIsolatedCacheByEntityType <IDomain>(); // note: must do what's above FIRST else the repositories still have the old cached // content and when the PublishedCachesService is notified of changes it does not see // the new content... // notify _publishedSnapshotService.Notify(assignedDomains.Select(x => new DomainCacheRefresher.JsonPayload(x.Id, DomainChangeTypes.Remove)).ToArray()); } } // note: must do what's above FIRST else the repositories still have the old cached // content and when the PublishedCachesService is notified of changes it does not see // the new content... // TODO: what about this? // should rename it, and then, this is only for Deploy, and then, ??? //if (Suspendable.PageCacheRefresher.CanUpdateDocumentCache) // ... _publishedSnapshotService.Notify(payloads, out _, out var publishedChanged); if (payloads.Any(x => x.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) || publishedChanged) { // when a public version changes AppCaches.ClearPartialViewCache(); } base.Refresh(payloads); }