public static void RemoveMacroCache(this DistributedCache dc, macro macro)
 {
     if (macro == null || macro.Model == null)
     {
         return;
     }
     dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
 }
Ejemplo n.º 2
0
 public static void RemoveMacroCache(this DistributedCache dc, IMacro macro)
 {
     if (macro == null)
     {
         return;
     }
     dc.RefreshByJson(MacroCacheRefresher.UniqueId, MacroCacheRefresher.Serialize(macro));
 }
 public static void RemoveMacroCache(this DistributedCache dc, global::umbraco.cms.businesslogic.macro.Macro macro)
 {
     if (macro == null)
     {
         return;
     }
     dc.RefreshByJson(DistributedCache.MacroCacheRefresherGuid, MacroCacheRefresher.SerializeToJsonPayload(macro));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Removes the cache amongst servers for a macro item
 /// </summary>
 /// <param name="dc"></param>
 /// <param name="macro"></param>
 public static void RemoveMacroCache(this DistributedCache dc, macro macro)
 {
     if (macro != null && macro.Model != null)
     {
         dc.RefreshByJson(new Guid(DistributedCache.MacroCacheRefresherId),
                          MacroCacheRefresher.SerializeToJsonPayload(macro));
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Refreshes the cache amongst servers for a macro item
 /// </summary>
 /// <param name="dc"></param>
 /// <param name="macro"></param>
 public static void RefreshMacroCache(this DistributedCache dc, global::umbraco.cms.businesslogic.macro.Macro macro)
 {
     if (macro != null)
     {
         dc.RefreshByJson(new Guid(DistributedCache.MacroCacheRefresherId),
                          MacroCacheRefresher.SerializeToJsonPayload(macro));
     }
 }
        public static void RefreshContentTypes(CacheHelper cacheHelper)
        {
            // we could try to have a mechanism to notify the PublishedCachesService
            // and figure out whether published items were modified or not... keep it
            // simple for now, just clear the whole thing

            cacheHelper.ClearPartialViewCache();
            MacroCacheRefresher.ClearMacroContentCache(cacheHelper); // just the content

            cacheHelper.IsolatedRuntimeCache.ClearCache <PublicAccessEntry>();
            cacheHelper.IsolatedRuntimeCache.ClearCache <IContent>();
        }
        public override void Refresh(JsonPayload[] payloads)
        {
            CacheHelper.RuntimeCache.ClearCacheObjectTypes <PublicAccessEntry>();

            var idsRemoved    = new HashSet <int>();
            var isolatedCache = CacheHelper.IsolatedRuntimeCache.GetOrCreateCache <IContent>();

            foreach (var payload in payloads)
            {
                isolatedCache.ClearCacheItem(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.ClearCacheObjectTypes <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)
                {
                    //fixme - 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...

            // fixme - 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
                Current.ApplicationCache.ClearPartialViewCache();
                MacroCacheRefresher.ClearMacroContentCache(CacheHelper); // just the content
            }

            base.Refresh(payloads);
        }