private void SetDependecies(string rawUrl, ContentRenderingTrackerContext contentRenderingContext)
 {
     foreach (var contentLanguageReference in contentRenderingContext.ContentItems)
     {
         //for now we skip content language, meaning a change in one language evicts all language versions
         //_htmlCache.AddDependency(_contentCacheKeyCreator.CreateLanguageCacheKey(contentLanguageReference.ContentLink, contentLanguageReference.Language.Name), rawUrl);
         _htmlCache.AddDependency(_contentCacheKeyCreator.CreateCommonCacheKey(contentLanguageReference.ContentLink), rawUrl);
     }
     foreach (var contentLink in contentRenderingContext.ChildrenListings)
     {
         _htmlCache.AddDependency(_contentCacheKeyCreator.CreateChildrenCacheKey(contentLink, null), rawUrl);
     }
 }
Пример #2
0
        public void CompleteContext(IRenderingContext currentContext, string htmlResult)
        {
            var parentContext = currentContext.ParentContext;

            //If something should not be cached like a personalized content area item, then we should not cache the content area as whole either
            if (parentContext != null && currentContext.PreventCache)
            {
                parentContext.PreventCache = currentContext.PreventCache;
            }

            if (!currentContext.PreventCache && !_principalAccessor.Principal.Identity.IsAuthenticated)
            {
                _htmlCache.Set(currentContext.Key, htmlResult);
                if (parentContext != null)
                {
                    _htmlCache.AddDependency($"{DependencyPrefix}{currentContext.Key}", parentContext.Key);
                }

                if (currentContext.DependentOnAllContent)
                {
                    _htmlCache.AddDependency(AllDependencyKey, currentContext.Key);
                }
                else
                {
                    foreach (var contentLink in currentContext.ContentItems)
                    {
                        _htmlCache.AddDependency($"{DependencyPrefix}{contentLink.ToReferenceWithoutVersion()}", currentContext.Key);
                    }

                    foreach (var childListing in currentContext.Listings)
                    {
                        _htmlCache.AddDependency($"{ListingDependencyPrefix}{childListing.ToReferenceWithoutVersion()}", currentContext.Key);
                    }
                }
            }
            _requestCache.Set(ContextKey, parentContext);
        }