DataCacheHelper.GetCachedX<>() and dependencies

Stefan Lorenz asked on March 19, 2014 04:40

Hi,

I understand adding dependencies to cached data when using CacheHelper.Add():

CacheHelper.Add(.....,CacheHelper.GetCacheDependency(...),....);

But I wonder how to set dependencies when using one of the DataCacheHelper.GetCachedX methods? They don't accept a CMSCacheDependency object, but instead want a dependency callback (the 2nd last parameter). All examples I found have this parameter set to null.

Would anyone mind giving me a quick example how to define a cache dependency when using GetCachedX() ?

Thanks in advance Stefan

Recent Answers


Roman Koníček answered on April 14, 2014 08:52

Hi Stefan,

Setting dependencies via DataCacheHelper.GetCachedX methods is obsolete, you should use CacheHelper.Add method to store the content in the cache (http://devnet.kentico.com/articles/deep-dive---kentico-cms-caching) or you can also use CachedSection (http://devnet.kentico.com/articles/new-in-5-5-caching-api-changes).

Also these two articles below might be useful for you:

http://devnet.kentico.com/docs/7_0/devguide/index.html?caching_in_custom_code.htm

http://devnet.kentico.com/articles/caching-api-examples

Do you have any specific reason, why you need to use the methods you have mentioned? If you can describe me your aim in more detail, I would help with the solution.

Best Regards, Roman Konicek

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.