Search Results for

    Show / Hide Table of Contents

    Class MicroCache

    Summary description for MicroCache.

    Inheritance
    System.Object
    MicroCache
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: ImageVault.Common.Data.Caching
    Assembly: ImageVault.Common.dll
    Syntax
    public class MicroCache

    Constructors

    MicroCache(Int32, Int32)

    Initializes a new instance of the MicroCache class.

    Declaration
    public MicroCache(int cacheDuration = 10, int cleanupThreshold = 10000)
    Parameters
    Type Name Description
    System.Int32 cacheDuration

    The number of seconds that the cache should be valid, defaults to 10 sec.

    System.Int32 cleanupThreshold

    The threshold limit when the items should be cleared to not be an ever growing pain in the 4$$.

    Fields

    Instance

    Singleton instance

    Declaration
    public static MicroCache Instance
    Field Value
    Type Description
    MicroCache

    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, 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, 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