November Happy Hour will be moved to Thursday December 5th.

CacheEvictionPolicy for descendant pages

Vote:
 

Hi,

I need to create a cache eviction policy that is covering changes on all descendant pages of a page. With IContentCacheKeyCreator.CreateChildrenCacheKey I can create a cache key for all child pages of a page. Can I use IContentCacheKeyCreator.CreateSegmentCacheKey in someway to achieve this?

Regards,
Jimmy

#148269
May 09, 2016 8:58
Vote:
 

Hi,


The following should do:

CacheManager.Insert(cacheKey,
                    objectToCache,
                    new CacheEvictionPolicy(
                        new string[1] {DataFactoryCache.ChildrenCacheKey(parentPage.ContentLink)},
                        TimeSpan.FromMinutes(5),
                        CacheTimeoutType.Sliding));

Thanks, M

#148291
May 09, 2016 13:53
Vote:
 

Hi,

DataFactoryCache.ChildrenCacheKey is deprecated, so I used IContentCacheKeyCreator.CreateChildrenCacheKey instead. Like this;

var expiration = TimeSpan.FromSeconds(timeoutInSeconds);
var cacheKeys = new List<string>() { _contentCacheKeyCreator.CreateChildrenCacheKey(contentReference, null) };
var evictionPolicy = new CacheEvictionPolicy(expiration, CacheTimeoutType.Absolute, cacheKeys);


The problem is that the cachekey generated from CreateChildrenCacheKey only covers the child pages. I want my cache to be refreshed when ANY descendant page is updated.

/Jimmy

#148317
Edited, May 10, 2016 8:02
Vote:
 

I created my own caching invalidation for this reason (you can have descendants and also contenttype as dependency). Then in content events I check updated/created/deleted/moved pages and invalidate cache. It was for an older version though. I'll try to blog about it in a few days and port it to the latest version :)

#148321
May 10, 2016 9:29
Vote:
 

Thanks Daniel! Using contenttype as dependency might work for me.

/Jimmy

#148322
May 10, 2016 9:41
Vote:
 
#148480
May 13, 2016 18:03
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.