Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

CachingExtensions.cs

namespace Nop.Core.Caching;

public static class CachingExtensions
{
    /// 
    /// Get a cached item. If it's not in the cache yet, then load and cache it.
    /// NOTE: this method is only kept for backwards compatibility: the async overload is preferred!
    /// 
    /// Type of cached item
    /// Cache manager
    /// Cache key
    /// Function to load item if it's not in the cache yet
    /// The cached value associated with the specified key
    public static T Get(this IStaticCacheManager cacheManager, CacheKey key, Func acquire)
    {
        return cacheManager.GetAsync(key, acquire).GetAwaiter().GetResult();
    }

    /// 
    /// Remove items by cache key prefix
    /// 
    /// Cache manager
    /// Cache key prefix
    /// Parameters to create cache key prefix
    public static void RemoveByPrefix(this IStaticCacheManager cacheManager, string prefix, params object[] prefixParameters)
    {
        cacheManager.RemoveByPrefixAsync(prefix, prefixParameters).Wait();
    }
}