You can refresh the Umbraco memory cache programmatically by using the DistributedCache service. Here’s a simple example:
using Umbraco.Cms.Core.Cache;
public class CacheHelper{
private readonly DistributedCache _distributedCache;
public CacheHelper(DistributedCache distributedCache)
{
_distributedCache = distributedCache;
}
// Method to refresh all published snapshots in the distributed cache, effectively refreshing the memory cache.
public void RefreshMemoryCache()
{
_distributedCache.RefreshAllPublishedSnapshot();
}}
Refresh Umbraco Memory Cache from code in v10
Maybe somebody has a code example of how to refresh Memory Cache from code instead of doing it manually in the Settings section.
Alex
Hi Alex,
You can refresh the Umbraco memory cache programmatically by using the DistributedCache service. Here’s a simple example:
Hope this is what you are looking for.
Hi Afreed
Thank you so much, let me test
is working on a reply...