Show / Hide Table of Contents

    Interface ICacheProvider

    Defines interface for a class providing access to a cache.

    Namespace: Nevatech.Vsb.Repository.Caching
    Assembly: Nevatech.Vsb.Repository.dll
    Syntax
    public interface ICacheProvider

    Methods

    Delete(String)

    Deletes a key from cache.

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

    The key to delete.

    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
    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
    Back to top Nevatech Sentinet 6.5 Online Documentation