Content provider caching strategy

Vote:
 

Hi,

I've created a custom content provider. I want to set a low cache setting on list methods (GetChildren e.g.) but still keep all IContent objects in the cache, since the construction of these objects are very expensive. Is there an easy way to do this with the built-in cache, or do I need to add caching between my content provider and data source? I've been looking at

void SetCacheSettings(ContentReference contentReference, IEnumerable children, CacheSettings cacheSettings)

But that method seems clear to the IContent objects as well, not just the ContentReferences in the children list?

The reason for all this is that I don't know when new objects are added or removed from the data source, but once they are added, they're pretty static.

Thanks!

#114273
Dec 09, 2014 0:17
Vote:
 

This was easy to fix, just override SetCacheSettings (the one with IEnumerable<GetChildrenReferenceResult>) in the provider:

protected override void SetCacheSettings(ContentReference contentReference, IEnumerable<GetChildrenReferenceResult> children, CacheSettings cacheSettings)
{
    // Set a low cache setting so new items are fetched from data source, but keep the
    // items already fetched for a long time in the cache.
    cacheSettings.SlidingExpiration = TimeSpan.FromSeconds(30);

    base.SetCacheSettings(contentReference, children, cacheSettings);
}
#118082
Edited, Feb 26, 2015 20:24
Vote:
 

Hi Johan!

This works if you are on the same domain i can see. But we use it on a multisite with several domain and appPools, any idea how to do then?

#120104
Apr 10, 2015 10:30
Vote:
 

That should not really be a problem. Sure, there can be some discrepancy in the cache. But in my case I was not using any of the list methods in IContentLoader, only in edit mode.

#120149
Apr 10, 2015 18:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.