Try our conversational search powered by Generative AI!

Caching

Vote:
 

Is there a tutoiral or some working example code for caching? I tried finding something but couldn't see any good examples. 

Most of the time its just bits and pieces. 

#184676
Nov 02, 2017 8:52
Vote:
 

not sure, what are you looking for, but if you want to use ISynchronizedObjectInstanceCache cache, this is how you can do

//ISynchronizedObjectInstanceCache _synchronizedObjectInstanceCache injected in constructor

var cacheKey = $"YOURCACHEKEY";
var cacheValue = _synchronizedObjectInstanceCache.Get(cacheKey) as YourModel;
if (cacheValue != null)
return cacheValue;

var yourModel = GetYourModel();
_synchronizedObjectInstanceCache.Insert(cacheKey, yourModel, Global.AbsoluteCacheEvictionPolicy_Short);

#184681
Nov 02, 2017 10:24
Vote:
 

Thanks Khan for the response. 

Which constructor am I going to inject //ISynchronizedObjectInstanceCache _synchronizedObjectInstanceCache?

Where am I getting the cache key? 

That is what I was saying that I couldn't find any proper tutorial. 

#184682
Nov 02, 2017 10:30
Vote:
 

Thanks for the response Khan. 

What I don't get is which constructor should I pass this ISynchronizedObjectInstanceCache _synchronizedObjectInstanceCache into?

Also, how do I configure the cache server? I mean don't I have to set somewhere cache urls for local server and remote server etc?

#184683
Nov 02, 2017 10:33
Vote:
 

Google is my friend, https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Caching/Object-caching/

#184685
Nov 02, 2017 10:43
Vote:
 

Thanks but I have looked into this and couldn't find the proper solution maybe I am missing something. But thanks anyway I will keep looking. 

#184686
Nov 02, 2017 10:45
* 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.