Dear DynamicWeb,
How can I define the SlidingExpiration time, when I implement MemoryCache in a custom class that implements this interface ICacheStorage? For now it seems to be hardcoded to 10 minutes.
Best regards, Anders
Dear DynamicWeb,
How can I define the SlidingExpiration time, when I implement MemoryCache in a custom class that implements this interface ICacheStorage? For now it seems to be hardcoded to 10 minutes.
Best regards, Anders
Hey Anders.
From the source code, it seems that the MemoryCache class doesn't implement a way to override the setting which is hardcoded in the class CacheItemPolicy static prop DefaultStoragePolicy.
I hope this clearifies your options :)
Best regards, Theodor
Hi Theodor,
Thanks for the reply, that was the same conclusion from my side, but hopefully I am missing something obvious about how to implement a difference policy.
Best regards, Anders
You can override default expiration - for all memory caches.
CacheItemPolicy.DefaultStoragePolicy.SlidingExpiration = TimeSpan.FromMinutes(30);
(please don't)
We can add an option to overrule the default of specific instances to using e.g. SetExpiration().
But please do not set it to something crazy - TimeSpan.FromMinutes(300000)
It will happen and server will cry and die.... :-)
You can override default expiration - for all memory caches.
CacheItemPolicy.DefaultStoragePolicy.SlidingExpiration = TimeSpan.FromMinutes(30);
(please don't)
We can add an option to overrule the default of specific instances to using e.g. SetExpiration().
But please do not set it to something crazy - TimeSpan.FromMinutes(300000)
It will happen and server will cry and die.... :-)
Dear Nicolai,
Yes, thank you, that will be very nice to be able to override the Expiration or maybe even better; to override the policy itself?
Best regards, Anders
I have added a suggestion to add two new methods. MemoryCache.SetExpiration and MemoryCache.SetCustomCacheItemPolicy
This has not been discussed with architect team yet, so consider it a proposal for now.
Very nice, Nicolai! Thank you so much! :-)
You must be logged in to post in the forum