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); }
protected override void PersistUpdatedItem(IDictionaryItem entity) { entity.UpdatingEntity(); foreach (var translation in entity.Translations) { translation.Value = translation.Value.ToValidXmlString(); } var dto = DictionaryItemFactory.BuildDto(entity); Database.Update(dto); foreach (var translation in entity.Translations) { var textDto = DictionaryTranslationFactory.BuildDto(translation, entity.Key); if (translation.HasIdentity) { Database.Update(textDto); } else { translation.Id = Convert.ToInt32(Database.Insert(textDto)); translation.Key = entity.Key; } } entity.ResetDirtyProperties(); //Clear the cache entries that exist by uniqueid/item key IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, string>(entity.ItemKey)); IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, Guid>(entity.Key)); }
private IEnumerable <IMember> MapDtosToContent(List <MemberDto> dtos, bool withCache = false) { var temps = new List <TempContent <Member> >(); var contentTypes = new Dictionary <int, IMemberType?>(); var content = new Member[dtos.Count]; for (var i = 0; i < dtos.Count; i++) { MemberDto dto = dtos[i]; if (withCache) { // if the cache contains the (proper version of the) item, use it IMember?cached = IsolatedCache.GetCacheItem <IMember>(RepositoryCacheKeys.GetKey <IMember, int>(dto.NodeId)); if (cached != null && cached.VersionId == dto.ContentVersionDto.Id) { content[i] = (Member)cached; continue; } } // else, need to build it // get the content type - the repository is full cache *but* still deep-clones // whatever comes out of it, so use our own local index here to avoid this var contentTypeId = dto.ContentDto.ContentTypeId; if (contentTypes.TryGetValue(contentTypeId, out IMemberType? contentType) == false) { contentTypes[contentTypeId] = contentType = _memberTypeRepository.Get(contentTypeId); } Member c = content[i] = ContentBaseFactory.BuildEntity(dto, contentType); // need properties var versionId = dto.ContentVersionDto.Id; temps.Add(new TempContent <Member>(dto.NodeId, versionId, 0, contentType, c)); } // load all properties for all documents from database in 1 query - indexed by version id IDictionary <int, PropertyCollection> properties = GetPropertyCollections(temps); // assign properties foreach (TempContent <Member> temp in temps) { if (temp.Content is not null) { temp.Content.Properties = properties[temp.VersionId]; // reset dirty initial properties (U4-1946) temp.Content.ResetDirtyProperties(false); } } return(content); }
public override void Remove(int id) { var cache = CacheHelper.IsolatedRuntimeCache.GetCache <IRelationType>(); if (cache) { cache.Result.ClearCacheItem(RepositoryCacheKeys.GetKey <IRelationType>(id)); } base.Remove(id); }
public override void Refresh(int id) { var cache = AppCaches.IsolatedCaches.Get <IRelationType>(); if (cache) { cache.Result.Clear(RepositoryCacheKeys.GetKey <IRelationType>(id)); } base.Refresh(id); }
public override void Remove(int id) { var cache = AppCaches.IsolatedCaches.Get <IRelationType>(); if (cache.Success) { cache.Result?.Clear(RepositoryCacheKeys.GetKey <IRelationType, int>(id)); } base.Remove(id); }
public override void Remove(int id) { var userCache = CacheHelper.IsolatedRuntimeCache.GetCache <IUser>(); if (userCache) { userCache.Result.ClearCacheItem(RepositoryCacheKeys.GetKey <IUser>(id)); } base.Remove(id); }
public override void Refresh(int id) { Attempt <IAppPolicyCache?> cache = AppCaches.IsolatedCaches.Get <IRelationType>(); if (cache.Success) { cache.Result?.Clear(RepositoryCacheKeys.GetKey <IRelationType, int>(id)); } base.Refresh(id); }
/// <inheritdoc /> protected override void PersistUpdatedItem(IConsent entity) { entity.UpdatingEntity(); ConsentDto dto = ConsentFactory.BuildDto(entity); Database.Update(dto); entity.ResetDirtyProperties(); IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IConsent, int>(entity.Id)); }
public override void Remove(int id) { var userCache = AppCaches.IsolatedCaches.Get <IUser>(); if (userCache) { userCache.Result.Clear(RepositoryCacheKeys.GetKey <IUser>(id)); } base.Remove(id); }
private void ClearCache(int id) { _idkMap.ClearCache(id); AppCaches.ClearPartialViewCache(); var memberCache = AppCaches.IsolatedCaches.Get <IMember>(); if (memberCache) { memberCache.Result.Clear(RepositoryCacheKeys.GetKey <IMember>(id)); } }
private void ClearCache(int id) { _idkMap.ClearCache(id); CacheHelper.ClearPartialViewCache(); var memberCache = CacheHelper.IsolatedRuntimeCache.GetCache <IMember>(); if (memberCache) { memberCache.Result.ClearCacheItem(RepositoryCacheKeys.GetKey <IMember>(id)); } }
protected override void PersistDeletedItem(IDictionaryItem entity) { RecursiveDelete(entity.Key); Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = entity.Key }); Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = entity.Key }); //Clear the cache entries that exist by uniqueid/item key IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, string>(entity.ItemKey)); IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, Guid>(entity.Key)); entity.DeleteDate = DateTime.Now; }
public override void Remove(int id) { Attempt <IAppPolicyCache?> userGroupCache = AppCaches.IsolatedCaches.Get <IUserGroup>(); if (userGroupCache.Success) { userGroupCache.Result?.Clear(RepositoryCacheKeys.GetKey <IUserGroup, int>(id)); userGroupCache.Result?.ClearByKey(CacheKeys.UserGroupGetByAliasCacheKeyPrefix); } // we don't know what user's belong to this group without doing a look up so we'll need to just clear them all ClearAllIsolatedCacheByEntityType <IUser>(); base.Remove(id); }
public override void Remove(int id) { Attempt <IAppPolicyCache?> userCache = AppCaches.IsolatedCaches.Get <IUser>(); if (userCache.Success) { userCache.Result?.Clear(RepositoryCacheKeys.GetKey <IUser, int>(id)); userCache.Result?.ClearByKey(CacheKeys.UserContentStartNodePathsPrefix + id); userCache.Result?.ClearByKey(CacheKeys.UserMediaStartNodePathsPrefix + id); userCache.Result?.ClearByKey(CacheKeys.UserAllContentStartNodesPrefix + id); userCache.Result?.ClearByKey(CacheKeys.UserAllMediaStartNodesPrefix + id); } base.Remove(id); }
public override void Remove(int id) { var userGroupCache = CacheHelper.IsolatedRuntimeCache.GetCache <IUserGroup>(); if (userGroupCache) { userGroupCache.Result.ClearCacheItem(RepositoryCacheKeys.GetKey <IUserGroup>(id)); userGroupCache.Result.ClearCacheByKeySearch(UserGroupRepository.GetByAliasCacheKeyPrefix); } //we don't know what user's belong to this group without doing a look up so we'll need to just clear them all ClearAllIsolatedCacheByEntityType <IUser>(); base.Remove(id); }
private void ClearCache(params JsonPayload[] payloads) { AppCaches.ClearPartialViewCache(); var memberCache = AppCaches.IsolatedCaches.Get <IMember>(); foreach (var p in payloads) { _idkMap.ClearCache(p.Id); if (memberCache) { memberCache.Result.Clear(RepositoryCacheKeys.GetKey <IMember, int>(p.Id)); memberCache.Result.Clear(RepositoryCacheKeys.GetKey <IMember, string>(p.Username)); } } }
public override void Remove(int id) { var userCache = AppCaches.IsolatedCaches.Get <IUser>(); if (userCache) { userCache.Result.Clear(RepositoryCacheKeys.GetKey <IUser>(id)); userCache.Result.ClearByKey(CacheKeys.UserContentStartNodePathsPrefix + id); userCache.Result.ClearByKey(CacheKeys.UserMediaStartNodePathsPrefix + id); userCache.Result.ClearByKey(CacheKeys.UserAllContentStartNodesPrefix + id); userCache.Result.ClearByKey(CacheKeys.UserAllMediaStartNodesPrefix + id); } base.Remove(id); }
private void RecursiveDelete(Guid parentId) { var list = Database.Fetch <DictionaryDto>("WHERE parent = @ParentId", new { ParentId = parentId }); foreach (var dto in list) { RecursiveDelete(dto.UniqueId); Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = dto.UniqueId }); Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = dto.UniqueId }); //Clear the cache entries that exist by uniqueid/item key IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, string>(dto.Key)); IsolatedCache.Clear(RepositoryCacheKeys.GetKey <IDictionaryItem, Guid>(dto.UniqueId)); } }
public override void Refresh(JsonPayload[] payloads) { if (payloads == null) { return; } _publishedSnapshotService.Notify(payloads, out var anythingChanged); if (anythingChanged) { AppCaches.ClearPartialViewCache(); AppCaches.RuntimeCache.ClearByKey(CacheKeys.MediaRecycleBinCacheKey); var mediaCache = AppCaches.IsolatedCaches.Get <IMedia>(); foreach (var payload in payloads) { if (payload.ChangeTypes == TreeChangeTypes.Remove) { _idKeyMap.ClearCache(payload.Id); } if (!mediaCache) { continue; } // repository cache // it *was* done for each pathId but really that does not make sense // only need to do it for the current media mediaCache.Result.Clear(RepositoryCacheKeys.GetKey <IMedia, int>(payload.Id)); mediaCache.Result.Clear(RepositoryCacheKeys.GetKey <IMedia, Guid?>(payload.Key)); // remove those that are in the branch if (payload.ChangeTypes.HasTypesAny(TreeChangeTypes.RefreshBranch | TreeChangeTypes.Remove)) { var pathid = "," + payload.Id + ","; mediaCache.Result.ClearOfType <IMedia>((_, v) => v.Path.Contains(pathid)); } } } base.Refresh(payloads); }
public override void Refresh(JsonPayload[] payloads) { foreach (var payload in payloads) { foreach (var alias in GetCacheKeysForAlias(payload.Alias)) { AppCaches.RuntimeCache.ClearByKey(alias); } var macroRepoCache = AppCaches.IsolatedCaches.Get <IMacro>(); if (macroRepoCache) { macroRepoCache.Result.Clear(RepositoryCacheKeys.GetKey <IMacro, int>(payload.Id)); macroRepoCache.Result.Clear(RepositoryCacheKeys.GetKey <IMacro, string>(payload.Alias)); // Repository caching of macro definition by alias } } base.Refresh(payloads); }
public override void Refresh(string json) { var payloads = Deserialize(json); foreach (var payload in payloads) { foreach (var alias in GetCacheKeysForAlias(payload.Alias)) { AppCaches.RuntimeCache.ClearByKey(alias); } var macroRepoCache = AppCaches.IsolatedCaches.Get <IMacro>(); if (macroRepoCache) { macroRepoCache.Result.Clear(RepositoryCacheKeys.GetKey <IMacro, int>(payload.Id)); } } base.Refresh(json); }
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) { 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); }