Show / Hide Table of Contents

    Class MemoryCacheProvider

    Implements the ICacheProvider that stores values in the local memory.

    Inheritance
    Object
    MemoryCacheProvider
    Implements
    ICacheProvider
    IDisposable
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Nevatech.Vsb.Repository.Caching
    Assembly: Nevatech.Vsb.Repository.dll
    Syntax
    public sealed class MemoryCacheProvider : ICacheProvider, IDisposable

    Constructors

    MemoryCacheProvider()

    Declaration
    public MemoryCacheProvider()

    Fields

    CacheName

    Name of the cache configuration (used in application configuration file).

    Declaration
    public const string CacheName = "Nevatech.Vsb.Runtime.MessageCache"
    Field Value
    Type Description
    String

    Methods

    Delete(String)

    Deletes a key from cache.

    Declaration
    public void Delete(string key)
    Parameters
    Type Name Description
    String key

    The key to delete.

    Dispose()

    Releases internal cache.

    Declaration
    public void Dispose()

    GetOrSet<T>(String, Func<T>, Func<T, T>, Nullable<TimeSpan>, Boolean)

    Gets a string value from cache. If value does not exist, it may be optionally created. If it exists, it may be optionally updated. This operation is atomic.

    Declaration
    public T GetOrSet<T>(string key, Func<T> createValue = null, Func<T, T> updateValue = null, TimeSpan? expiry = default(TimeSpan? ), bool updateExpiry = false)
    Parameters
    Type Name Description
    String key

    The cache key at which cached string value is stored.

    Func<T> createValue

    A method returning a new value for caching that is invoked, if cache entry is not found.

    Func<T, T> updateValue

    A method returning an updated value for caching that is invoked if existing cache entry is found.

    Nullable<TimeSpan> expiry

    A timeout on key. After the timeout has expired, the key will automatically be deleted. Setting this value to null will remove the timeout (make key persistent).

    Boolean updateExpiry

    True to update existing key expiry to a new value (sliding expiration). The default value is false.

    Returns
    Type Description
    T

    The cached value or default(T), if cache entry was not found and was not created.

    Type Parameters
    Name Description
    T

    Implements

    ICacheProvider
    System.IDisposable
    Back to top Nevatech Sentinet 6.5 Online Documentation