Example #1
0
        /// <summary>
        /// Updates any Cache Objects that are associated with this entity
        /// </summary>
        /// <param name="entityState">State of the entity.</param>
        /// <param name="dbContext">The database context.</param>
        public void UpdateCache(EntityState entityState, Rock.Data.DbContext dbContext)
        {
            BlockCache.UpdateCachedEntity(this.Id, entityState);

            var model = this;

            if (model.SiteId.HasValue && model.SiteId != originalSiteId)
            {
                PageCache.FlushPagesForSite(model.SiteId.Value);
            }
            else if (model.LayoutId.HasValue && model.LayoutId != originalLayoutId)
            {
                PageCache.FlushPagesForLayout(model.LayoutId.Value);
            }

            if (originalSiteId.HasValue)
            {
                PageCache.FlushPagesForSite(originalSiteId.Value);
            }
            else if (originalLayoutId.HasValue)
            {
                PageCache.FlushPagesForLayout(originalLayoutId.Value);
            }
            else if (originalPageId.HasValue)
            {
                PageCache.FlushItem(originalPageId.Value);
            }
        }
Example #2
0
        /// <summary>
        /// Updates any Cache Objects that are associated with this entity
        /// </summary>
        /// <param name="entityState">State of the entity.</param>
        /// <param name="dbContext">The database context.</param>
        public void UpdateCache(System.Data.Entity.EntityState entityState, Rock.Data.DbContext dbContext)
        {
            BlockCache.UpdateCachedEntity(this.Id, entityState);

            var model = this;

            if (model.SiteId.HasValue && model.SiteId != originalSiteId)
            {
                PageCache.RemoveSiteBlocks(model.SiteId.Value);
            }
            else if (model.LayoutId.HasValue && model.LayoutId != originalLayoutId)
            {
                PageCache.RemoveLayoutBlocks(model.LayoutId.Value);
            }

            if (originalSiteId.HasValue)
            {
                PageCache.RemoveSiteBlocks(originalSiteId.Value);
            }
            else if (originalLayoutId.HasValue)
            {
                PageCache.RemoveLayoutBlocks(originalLayoutId.Value);
            }
            else if (originalPageId.HasValue)
            {
                var page = PageCache.Get(originalPageId.Value);
                page.RemoveBlocks();
            }
        }