Search Results for

    Show / Hide Table of Contents

    Class MicroCache

    Summary description for MicroCache.

    Inheritance
    System.Object
    MicroCache
    Namespace: ImageVault.Common.Data.Caching
    Assembly: ImageVault.Common.dll
    Syntax
    public class MicroCache : Object

    Constructors

    MicroCache(MicroCacheOptions, ILogger<MicroCache>)

    Initializes a new instance of the MicroCache class.

    Declaration
    public MicroCache(MicroCacheOptions options, ILogger<MicroCache> logger)
    Parameters
    Type Name Description
    MicroCacheOptions options

    The options for the micro cache to use

    Microsoft.Extensions.Logging.ILogger<MicroCache> logger

    Properties

    Enabled

    Controls if the cache should be enabled or not.

    Declaration
    public bool Enabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    Clear()

    Clears the entire cache

    Declaration
    public void Clear()

    Get(String)

    Gets the cached item

    Declaration
    public object Get(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Object

    GetOrCreate<T>(String, Func<String, T>, Nullable<TimeSpan>)

    Gets the cache value if it exists, or creates it and populates the cache if it is missing.

    Declaration
    public T GetOrCreate<T>(string name, Func<string, T> creator, Nullable<TimeSpan> cacheDuration = null)
    Parameters
    Type Name Description
    System.String name
    System.Func<System.String, T> creator
    System.Nullable<System.TimeSpan> cacheDuration

    An optional value on how long the value should be cached

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    GetOrCreateAsync<T>(String, Func<String, Task<T>>, Nullable<TimeSpan>)

    Declaration
    public Task<T> GetOrCreateAsync<T>(string name, Func<string, Task<T>> creator, Nullable<TimeSpan> cacheDuration = null)
    Parameters
    Type Name Description
    System.String name
    System.Func<System.String, System.Threading.Tasks.Task<T>> creator
    System.Nullable<System.TimeSpan> cacheDuration
    Returns
    Type Description
    System.Threading.Tasks.Task<T>
    Type Parameters
    Name Description
    T

    Invalidate(String)

    invalidates the cache with the supplied key.

    Declaration
    public void Invalidate(string name)
    Parameters
    Type Name Description
    System.String name

    Extension Methods

    EnumExtensions.GetNames<TEnum>(TEnum)
    In This Article
    Back to top (c) Meriworks 2002-2022