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

Expire cache on Custom Repository Items

Vote:
 

We've created a custom content asset provider repository which pulls data from an external data source. We've then used identity mapper and mapped it so that it can be used by EPiServer CMS. 

Our problem is that once the content asset is cached, episerver doesn't request for the live call again since its cached. 

We need to know how to expire that cache as well as what the duration of the cache is.

#248624
Edited, Feb 15, 2021 9:55
Vote:
 

How do you cache the content asset? If you use IObjectInstanceCache/ISynchronizedObjectInstanceCache (which is the recommended way), when you add an object to cache you can control how long before the cache will expire, using CacheEvictionPolicy 

if you want to remove the cache actively, just remove the cache key 

https://world.episerver.com/csclasslibraries/cms/EPiServer.Framework.Cache.IObjectInstanceCache?version=7

#248632
Feb 15, 2021 11:43
Vote:
 

So, we're not caching anything ourselves.

We just inherit from "ContentProvider" and then implement all the necessary operations. Unfortunately i'm not allowed to post hyperlinks, otherwise i would've posted a snippet.

public class MyContentProvider : ContentProvider

{

protected override IContent LoadContent(ContentReference contentLink, ILanguageSelector languageSelector){}

protected override IList<GetChildrenReferenceResult> LoadChildrenReferencesAndTypes(ContentReference contentLink, string languageID, out bool languageSpecific){}

}

This is what we do. Then ofcourse we hook it up to make this turn up in the Asset pane as a new tab.

The problem is that the results of "LoadChildrenReferencesAndTypes" is cached after the first call. And we're trying to figure out where it is cached and how we can expire it.

#249022
Feb 23, 2021 6:34
Vote:
 

I am looking into the implementation of ContentProvider, and can't find where the cache is implemented (Admittedly I could have missed something). Are you sure it is cached at that level, but not on higher level (IContentRepository for example)

#249045
Feb 23, 2021 8:42
Vote:
 

It could be at a higher level. We're not sure about that. 

Our content provider makes live API calls to an external data source. When we were debugging, we noticed that when we expand a node in the asset tree, live calls are going through, but the second time around, data turns up instantaneously, but its not making a live call. So we understand that its cached somewhere. We are trying to understand where exactly its cache (it must be SynchronizedObjectCache im guess) and how we can get the key if we need to expire it manually. 

Since our last update, we also found another function that we could override

protected override void SetCacheSettings(IContent content, CacheSettings cacheSettings){}

This allows us to set the cache interval, which is good, but we still have certain conditions where we would like to "manually" expire the cache.

#249127
Feb 24, 2021 9:48
Vote:
 

Hi Quan, do you have any further insight that could be helpful?

#249383
Mar 01, 2021 5:26
Quan Mai - Mar 01, 2021 9:23
Unfortunately no, I haven't had time to dig more into this. As always, you can reach out to developer support service for help
Vote:
 

Is that a paid/premium service? How would i go about doing that?

#249610
Mar 05, 2021 12:45
Vote:
 

Just reach out to support@episerver.com. it should not cost money, at least at the beginning. 

#249622
Mar 05, 2021 15:53
Vote:
 

Thanks Quan. I've proceeded to do so. 

#249696
Mar 08, 2021 7:41
* 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.