Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    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

  • Afreed 26 posts 151 karma points
    1 week ago
    Afreed
    1

    Hi Alex,

    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();
        }}
    

    Hope this is what you are looking for.

  • Alex Skrypnyk 6162 posts 24132 karma points MVP 8x admin c-trib
    1 week ago
    Alex Skrypnyk
    0

    Hi Afreed

    Thank you so much, let me test

Please Sign in or register to post replies

Write your reply to:

Draft