ClearProviderPagesFromCache is never called directly from EPiServer. It is method that custom implementers can call to flush all pages from a specific PageProvider.
If your custom object is dependent on a specific page then you would add a cache dependency to that page when the custom object is added to cache. Then you could have some code like:
string pageCacheKey = DataFactoryCache.PageCommonCacheKey(pageLink);
CacheManager.RuntimeCacheInsert("yourkey", yourObject, new CacheDependency (null, new string[1]{pageCacheKey}));
If you want your cached object to be removed when all pages from the page providers is removed (e.g. when whole Page cache is cleared e.g. by a change in a PageType etc or when somebody calls ClearProviderPagesFromCache) then you would add a dependency to the common key for the provider like:
string commonProviderKey = "EPPageProvider:" + ProviderKey;
CacheManager.RuntimeCacheInsert("yourkey", yourObject, new CacheDependency (null, new string[1]{commonProviderKey}));
Ps.
Unfortunately is the property ProviderCacheKey on PageProviderBase private which is why you have to construct it yourself as in commonProviderKey above. I have added a bug that we should change it to public.
Ds.
Thanks Johan
The second proposal was what I was looking for. In the end though I have solved with my own ClearCache() method where I clear my cached object and also call ClearProviderPagesFromCache().
The problem I got when adding the CacheDependency was that my cached object was cleared everytime when pages where added to the ProviderCache.
/Hans
I have a pageprovider where I want to clear a cached object when the
"ClearProviderPagesFromCache()" method is called. The cached object contains data from the source system.
The cached object is like the "XmlPages" in the XmlPageProvider.
Do I accomplish this by adding a CacheDependency when I cache my object or do I add my CacheKey in the SetCacheSettings methods?
I have read the article http://labs.episerver.com/en/Blogs/Johan-Bjornfot/Dates/2008/10/PageProvider---Control-the-page-cache/ but I'm not sure how to accomplish it.
Can anyone help me on the way?
Regards Hans