Webiant Logo Webiant Logo
  1. No results found.

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

NopEntityCacheDefaults.cs

namespace Nop.Core.Caching;

/// 
/// Represents default values related to caching entities
/// 
public static partial class NopEntityCacheDefaults where TEntity : BaseEntity
{
    /// 
    /// Gets an entity type name used in cache keys
    /// 
    public static string EntityTypeName => typeof(TEntity).Name.ToLowerInvariant();

    /// 
    /// Gets a key for caching entity by identifier
    /// 
    /// 
    /// {0} : entity id
    /// 
    public static CacheKey ByIdCacheKey => new($"Nop.{EntityTypeName}.byid.{{0}}", ByIdPrefix, Prefix);

    /// 
    /// Gets a key for caching entities by identifiers
    /// 
    /// 
    /// {0} : entity ids
    /// 
    public static CacheKey ByIdsCacheKey => new($"Nop.{EntityTypeName}.byids.{{0}}", ByIdsPrefix, Prefix);

    /// 
    /// Gets a key for caching all entities
    /// 
    public static CacheKey AllCacheKey => new($"Nop.{EntityTypeName}.all.", AllPrefix, Prefix);

    /// 
    /// Gets a key pattern to clear cache
    /// 
    public static string Prefix => $"Nop.{EntityTypeName}.";

    /// 
    /// Gets a key pattern to clear cache
    /// 
    public static string ByIdPrefix => $"Nop.{EntityTypeName}.byid.";

    /// 
    /// Gets a key pattern to clear cache
    /// 
    public static string ByIdsPrefix => $"Nop.{EntityTypeName}.byids.";

    /// 
    /// Gets a key pattern to clear cache
    /// 
    public static string AllPrefix => $"Nop.{EntityTypeName}.all.";
}