/// <summary>
        /// Executed when the cache updates, which means we can know what the new URL is for a given document
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="cacheRefresherEventArgs"></param>
        private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs cacheRefresherEventArgs)
        {
            // only on master / single, not on replicas!
            if (IsReplicaServer)
            {
                return;
            }

            // simply getting OldRoutes will register it in the request cache,
            // so whatever we do with it, try/finally it to ensure it's cleared

            try
            {
                foreach (var oldRoute in OldRoutes)
                {
                    // assuming we cannot have 'CacheUpdated' for only part of the infos else we'd need
                    // to set a flag in 'Published' to indicate which entities have been refreshed ok
                    CreateRedirect(oldRoute.Key, oldRoute.Value.Item1, oldRoute.Value.Item2);
                }
            }
            finally
            {
                OldRoutes.Clear();
                RequestCache.ClearCacheItem(ContextKey3);
            }
        }
Пример #2
0
        /// <summary>
        /// When the page cache is refreshed, we'll check if any articulate root nodes were included in the refresh, if so we'll set a flag
        /// on the current request to rebuild the routes at the end of the request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// This will also work for load balanced scenarios since this event executes on all servers
        /// </remarks>
        private static void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, Umbraco.Core.Cache.CacheRefresherEventArgs e)
        {
            if (UmbracoContext.Current == null)
            {
                return;
            }

            switch (e.MessageType)
            {
            case MessageType.RefreshById:
            case MessageType.RemoveById:
                var item = UmbracoContext.Current.ContentCache.GetById((int)e.MessageObject);
                if (item != null && item.DocumentTypeAlias.InvariantEquals("Articulate"))
                {
                    //ensure routes are rebuilt
                    ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes", () => true);
                }
                break;

            case MessageType.RefreshByInstance:
            case MessageType.RemoveByInstance:
                var content = e.MessageObject as IContent;
                if (content == null)
                {
                    return;
                }
                if (content.ContentType.Alias.InvariantEquals("Articulate"))
                {
                    //ensure routes are rebuilt
                    UmbracoContext.Current.Application.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes", () => true);
                }
                break;
            }
        }
 private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
 {
     if (e.MessageType == Umbraco.Core.Sync.MessageType.RefreshAll)
     {
         VortoUrlRouteCache.Current.StartNewCacheFile();
     }
 }
Пример #4
0
 private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
 {
     if (e.MessageType == MessageType.RefreshByInstance && e.MessageObject is IContent instance)
     {
         GuidToIdCache.TryAdd(instance);
     }
 }
        private static void CacheRefresherBaseOnCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs cacheRefresherEventArgs)
        {
            // Do not configure if Enterspeed is not configured in Umbraco
            if (EnterspeedContext.Current?.Configuration == null ||
                !EnterspeedContext.Current.Configuration.IsConfigured)
            {
                return;
            }

            var umbracoHelper = UmbracoContextHelper.GetUmbracoHelper();
            var jobs          = new List <EnterspeedJob>();

            switch (cacheRefresherEventArgs.MessageType)
            {
            case MessageType.RefreshById:
                var refreshContent =
                    umbracoHelper.TypedContent((int)cacheRefresherEventArgs.MessageObject);
                if (refreshContent != null)
                {
                    var culture = refreshContent.GetCulture()?.IetfLanguageTag?.ToLowerInvariant();
                    var now     = DateTime.UtcNow;
                    jobs.Add(new EnterspeedJob
                    {
                        ContentId = refreshContent.Id,
                        Culture   = culture,
                        JobType   = EnterspeedJobType.Publish,
                        State     = EnterspeedJobState.Pending,
                        CreatedAt = now,
                        UpdatedAt = now,
                    });
                }

                break;

            case MessageType.RefreshByInstance:
                var node = umbracoHelper.TypedContent(((IContent)cacheRefresherEventArgs.MessageObject).Id);
                if (node != null)
                {
                    var culture = node.GetCulture()?.IetfLanguageTag?.ToLowerInvariant();
                    var now     = DateTime.UtcNow;
                    jobs.Add(new EnterspeedJob
                    {
                        ContentId = node.Id,
                        Culture   = culture,
                        JobType   = EnterspeedJobType.Publish,
                        State     = EnterspeedJobState.Pending,
                        CreatedAt = now,
                        UpdatedAt = now,
                    });
                }

                break;
            }

            EnqueueJobs(jobs);
        }
        void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
        {
           // var a = (IContent) e.MessageObject;

           // if (a.ContentType.Alias != "BlogFolder" || a.ContentType.Alias != "BlogPost")
           //     return;

           //if(e.MessageType == MessageType.RefreshById || e.MessageType == MessageType.RefreshByInstance)
           //     sender.Remove(a);

        }
Пример #7
0
        /// <summary>
        /// Content cache was updated.
        /// </summary>
        private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender,
                                                     CacheRefresherEventArgs e)
        {
            var kind = e.MessageType;

            if (kind == MessageType.RefreshById || kind == MessageType.RemoveById)
            {
                var id = e.MessageObject as int?;
                if (id.HasValue)
                {
                    var contentService = ApplicationContext.Current.Services.ContentService;
                    var node           = contentService.GetById(id.Value);
                    if (node != null)
                    {
                        HandleChangedContent(new[] { node });
                    }
                }
            }
        }
Пример #8
0
        private void ContentService_RepublishAll(PageCacheRefresher sender, CacheRefresherEventArgs e)
        {
            if (e.MessageType == MessageType.RefreshAll && AllowProcessing)
            {
                var contents       = new Stack <Umbraco.Core.Models.IContent>();
                var contentService = ApplicationContext.Current.Services.ContentService;
                var found          = new List <Umbraco.Core.Models.IContent>();

                foreach (var content in contentService.GetChildren(Umbraco.Core.Constants.System.Root))
                {
                    if (content.Published)
                    {
                        contents.Push(content);
                    }
                }

                while (contents.Count != 0)
                {
                    var content = contents.Pop();
                    foreach (var child in contentService.GetChildren(content.Id))
                    {
                        if (child.Published)
                        {
                            contents.Push(child);
                        }
                    }
                    found.Add(content);
                    if (found.Count == BatchSize)
                    {
                        Sync(found.Select(x => x.Key), found);
                        found.Clear();
                        System.Threading.Thread.Sleep(BatchSleep);
                    }
                }

                Sync(found.Select(x => x.Key), found);
            }
        }
Пример #9
0
        /// <summary>
        /// When the page cache is refreshed, we'll check if any articulate root nodes were included in the refresh, if so we'll set a flag
        /// on the current request to rebuild the routes at the end of the request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// This will also work for load balanced scenarios since this event executes on all servers
        /// </remarks>
        private static void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, Umbraco.Core.Cache.CacheRefresherEventArgs e)
        {
            if (UmbracoContext.Current == null)
            {
                return;
            }

            switch (e.MessageType)
            {
            case MessageType.RefreshById:
            case MessageType.RemoveById:
                var item = UmbracoContext.Current.ContentCache.GetById((int)e.MessageObject);
                if (item != null && item.DocumentTypeAlias.InvariantEquals("Articulate"))
                {
                    //ensure routes are rebuilt
                    ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes", () => true);
                }
                break;

            case MessageType.RefreshByInstance:
            case MessageType.RemoveByInstance:
                var content = e.MessageObject as IContent;
                if (content == null)
                {
                    return;
                }
                //TODO: There is a case when there are URL conflicts with Articulate data that when the other data is unpublished
                // we'd want to rebuild articulate routes, but not sure how to handle that and we don't want to rebuild everytime
                // something is unpublished
                if (content.ContentType.Alias.InvariantEquals("Articulate"))
                {
                    //ensure routes are rebuilt
                    ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes", () => true);
                }
                break;
            }
        }
Пример #10
0
        /// <summary>
        /// Handles index management for all published content events - basically handling published/unpublished
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// This will execute on all servers taking part in load balancing
        /// </remarks>
        static void PublishedPageCacheRefresherCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
        {
            if (Suspendable.ExamineEvents.CanIndex == false)
            {
                return;
            }

            switch (e.MessageType)
            {
            case MessageType.RefreshById:
                var c1 = ApplicationContext.Current.Services.ContentService.GetById((int)e.MessageObject);
                if (c1 != null)
                {
                    ReIndexForContent(c1, true);
                }
                break;

            case MessageType.RemoveById:

                //This is triggered when the item has been unpublished or trashed (which also performs an unpublish).

                var c2 = ApplicationContext.Current.Services.ContentService.GetById((int)e.MessageObject);
                if (c2 != null)
                {
                    // So we need to delete the index from all indexes not supporting unpublished content.

                    DeleteIndexForEntity(c2.Id, true);

                    // We then need to re-index this item for all indexes supporting unpublished content

                    ReIndexForContent(c2, false);
                }
                break;

            case MessageType.RefreshByInstance:
                var c3 = e.MessageObject as IContent;
                if (c3 != null)
                {
                    ReIndexForContent(c3, true);
                }
                break;

            case MessageType.RemoveByInstance:

                //This is triggered when the item has been unpublished or trashed (which also performs an unpublish).

                var c4 = e.MessageObject as IContent;
                if (c4 != null)
                {
                    // So we need to delete the index from all indexes not supporting unpublished content.

                    DeleteIndexForEntity(c4.Id, true);

                    // We then need to re-index this item for all indexes supporting unpublished content

                    ReIndexForContent(c4, false);
                }
                break;

            case MessageType.RefreshAll:
            case MessageType.RefreshByJson:
            default:
                //We don't support these for examine indexing
                break;
            }
        }
Пример #11
0
 private void PageCacheRefresherCacheUpdated(PageCacheRefresher sender, Core.Cache.CacheRefresherEventArgs e)
 {
     // After content has been updated clear content finder cache.
     ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch("MultilingualContentFinder");
 }
Пример #12
0
 /// <summary>
 /// The page cache refresher cache updated event handler.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="CacheRefresherEventArgs"/> containing information about the event.</param>
 private void PageCacheRefresherCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
 {
     this.ClearCache();
 }
Пример #13
0
        /// <summary>
        /// When the page cache is refreshed, we'll check if any articulate root nodes were included in the refresh, if so we'll set a flag
        /// on the current request to rebuild the routes at the end of the request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// This will also work for load balanced scenarios since this event executes on all servers
        /// </remarks>
        void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, Umbraco.Core.Cache.CacheRefresherEventArgs e)
        {
            if (UmbracoContext.Current == null) return;

            switch (e.MessageType)
            {
                case MessageType.RefreshById:
                case MessageType.RemoveById:
                    var item = UmbracoContext.Current.ContentCache.GetById((int) e.MessageObject);
                    if (item != null && item.DocumentTypeAlias.InvariantEquals("Articulate"))
                    {
                        //add the unpublished entities to the request cache
                        ApplicationContext.Current.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes", () => true);
                    }
                    break;
                case MessageType.RefreshByInstance:
                case MessageType.RemoveByInstance:
                    var content = e.MessageObject as IContent;
                    if (content == null) return;
                    if (content.ContentType.Alias.InvariantEquals("Articulate"))
                    {
                        //add the unpublished entities to the request cache
                        UmbracoContext.Current.Application.ApplicationCache.RequestCache.GetCacheItem("articulate-refresh-routes", () => true);
                    }
                    break;
            }
        }
Пример #14
0
 private void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs e)
 {
     Cache.Instance.RemoveByPrefix(typeof(NodeGetterCachedProxy).ToString());
 }
 private void PageCacheRefresherOnCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs cacheRefresherEventArgs)
 {
     _logService.Debug <ClearDonutOutputCache>("PageCacheRefresherOnCacheUpdated");
     ClearCache();
 }
 private void PageCacheRefresherOnCacheUpdated(PageCacheRefresher sender,
                                               CacheRefresherEventArgs cacheRefresherEventArgs)
 {
     ClearCache();
 }
Пример #17
0
 private void PageCacheRefresherCacheUpdated(PageCacheRefresher sender, Core.Cache.CacheRefresherEventArgs e)
 {
     // After content has been updated clear content finder cache.
     this.ClearCache();
 }
 private void PageCacheRefresherOnCacheUpdated(PageCacheRefresher sender, CacheRefresherEventArgs cacheRefresherEventArgs)
 {
     Log.Debug("Clearing output cache");
     ClearCache();
 }