• CacheManager
  • Documentation
  • Api Docs
  • MichaCo.net
    Show / Hide Table of Contents

    Interface ICacheManager<TCacheValue>

    This interface extends the ICache interface by some cache manager specific methods and events.

    Inherited Members
    ICache<TCacheValue>.Item[String]
    ICache<TCacheValue>.Item[String, String]
    ICache<TCacheValue>.Add(String, TCacheValue)
    ICache<TCacheValue>.Add(String, TCacheValue, String)
    ICache<TCacheValue>.Add(CacheItem<TCacheValue>)
    ICache<TCacheValue>.Clear()
    ICache<TCacheValue>.ClearRegion(String)
    ICache<TCacheValue>.Exists(String)
    ICache<TCacheValue>.Exists(String, String)
    ICache<TCacheValue>.Get(String)
    ICache<TCacheValue>.Get(String, String)
    ICache<TCacheValue>.Get<TOut>(String)
    ICache<TCacheValue>.Get<TOut>(String, String)
    ICache<TCacheValue>.GetCacheItem(String)
    ICache<TCacheValue>.GetCacheItem(String, String)
    ICache<TCacheValue>.Put(String, TCacheValue)
    ICache<TCacheValue>.Put(String, TCacheValue, String)
    ICache<TCacheValue>.Put(CacheItem<TCacheValue>)
    ICache<TCacheValue>.Remove(String)
    ICache<TCacheValue>.Remove(String, String)
    IDisposable.Dispose()
    Namespace:CacheManager.Core
    Assembly:CacheManager.Core.dll
    Syntax
    public interface ICacheManager<TCacheValue> : ICache<TCacheValue>, IDisposable
    Type Parameters
    Name Description
    TCacheValue

    The type of the cache item value.

    Properties

    | Improve this Doc View Source

    CacheHandles

    Gets a list of cache handles currently registered within the cache manager.

    Declaration
    IEnumerable<BaseCacheHandle<TCacheValue>> CacheHandles { get; }
    Property Value
    Type Description
    IEnumerable<BaseCacheHandle<TCacheValue>>

    The cache handles.

    Remarks

    This list is read only, any changes to the returned list instance will not affect the state of the cache manager instance.

    | Improve this Doc View Source

    Configuration

    Gets the configuration.

    Declaration
    IReadOnlyCacheManagerConfiguration Configuration { get; }
    Property Value
    Type Description
    IReadOnlyCacheManagerConfiguration

    The configuration.

    | Improve this Doc View Source

    Name

    Gets the cache name.

    Declaration
    string Name { get; }
    Property Value
    Type Description
    String

    The cache name.

    Methods

    | Improve this Doc View Source

    AddOrUpdate(CacheItem<TCacheValue>, Func<TCacheValue, TCacheValue>)

    Adds an item to the cache or, if the item already exists, updates the item using the updateValue function.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue AddOrUpdate(CacheItem<TCacheValue> addItem, Func<TCacheValue, TCacheValue> updateValue)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> addItem

    The item which should be added or updated.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update, if the item does exist.

    Returns
    Type Description
    TCacheValue

    The value which has been added or updated, or null, if the update was not successful.

    Exceptions
    Type Condition
    ArgumentNullException

    If addItem or updateValue are null.

    | Improve this Doc View Source

    AddOrUpdate(CacheItem<TCacheValue>, Func<TCacheValue, TCacheValue>, Int32)

    Adds an item to the cache or, if the item already exists, updates the item using the updateValue function.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue AddOrUpdate(CacheItem<TCacheValue> addItem, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> addItem

    The item which should be added or updated.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update, if the item does exist.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return Null.

    Returns
    Type Description
    TCacheValue

    The value which has been added or updated, or null, if the update was not successful.

    Exceptions
    Type Condition
    ArgumentNullException

    If addItem or updateValue is null.

    | Improve this Doc View Source

    AddOrUpdate(String, TCacheValue, Func<TCacheValue, TCacheValue>)

    Adds an item to the cache or, if the item already exists, updates the item using the updateValue function.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue AddOrUpdate(string key, TCacheValue addValue, Func<TCacheValue, TCacheValue> updateValue)
    Parameters
    Type Name Description
    String key

    The key to update.

    TCacheValue addValue

    The value which should be added in case the item doesn't already exist.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update in case the item does already exist.

    Returns
    Type Description
    TCacheValue

    The value which has been added or updated, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or updateValue are null.

    | Improve this Doc View Source

    AddOrUpdate(String, TCacheValue, Func<TCacheValue, TCacheValue>, Int32)

    Adds an item to the cache or, if the item already exists, updates the item using the updateValue function.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue AddOrUpdate(string key, TCacheValue addValue, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
    Parameters
    Type Name Description
    String key

    The key to update.

    TCacheValue addValue

    The value which should be added in case the item doesn't already exist.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update in case the item does already exist.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return Null.

    Returns
    Type Description
    TCacheValue

    The value which has been added or updated, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or updateValue is null.

    | Improve this Doc View Source

    AddOrUpdate(String, String, TCacheValue, Func<TCacheValue, TCacheValue>)

    Adds an item to the cache or, if the item already exists, updates the item using the updateValue function.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue AddOrUpdate(string key, string region, TCacheValue addValue, Func<TCacheValue, TCacheValue> updateValue)
    Parameters
    Type Name Description
    String key

    The key to update.

    String region

    The region of the key to update.

    TCacheValue addValue

    The value which should be added in case the item doesn't already exist.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update in case the item does already exist.

    Returns
    Type Description
    TCacheValue

    The value which has been added or updated, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or region or updateValue are null.

    | Improve this Doc View Source

    AddOrUpdate(String, String, TCacheValue, Func<TCacheValue, TCacheValue>, Int32)

    Adds an item to the cache or, if the item already exists, updates the item using the updateValue function.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue AddOrUpdate(string key, string region, TCacheValue addValue, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
    Parameters
    Type Name Description
    String key

    The key to update.

    String region

    The region of the key to update.

    TCacheValue addValue

    The value which should be added in case the item doesn't already exist.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update in case the item does already exist.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return Null.

    Returns
    Type Description
    TCacheValue

    The value which has been added or updated, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or region or updateValue is null.

    | Improve this Doc View Source

    Expire(String, ExpirationMode, TimeSpan)

    Explicitly sets the expiration mode and timeout for the key in all cache layers. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void Expire(string key, ExpirationMode mode, TimeSpan timeout)
    Parameters
    Type Name Description
    String key

    The cache key.

    ExpirationMode mode

    The expiration mode.

    TimeSpan timeout

    The expiration timeout.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    Expire(String, DateTimeOffset)

    Explicitly sets an absolute expiration date for the key in all cache layers. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void Expire(string key, DateTimeOffset absoluteExpiration)
    Parameters
    Type Name Description
    String key

    The cache key.

    DateTimeOffset absoluteExpiration

    The expiration date. The value must be greater than zero.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    Expire(String, String, ExpirationMode, TimeSpan)

    Explicitly sets the expiration mode and timeout for the key in region in all cache layers. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void Expire(string key, string region, ExpirationMode mode, TimeSpan timeout)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    ExpirationMode mode

    The expiration mode.

    TimeSpan timeout

    The expiration timeout.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    Expire(String, String, DateTimeOffset)

    Explicitly sets an absolute expiration date for the key in region in all cache layers. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void Expire(string key, string region, DateTimeOffset absoluteExpiration)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    DateTimeOffset absoluteExpiration

    The expiration date. The value must be greater than zero.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    Expire(String, String, TimeSpan)

    Explicitly sets a sliding expiration date for the key in region in all cache layers. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void Expire(string key, string region, TimeSpan slidingExpiration)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    TimeSpan slidingExpiration

    The expiration timeout. The value must be greater than zero.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    Expire(String, TimeSpan)

    Explicitly sets a sliding expiration date for the key in all cache layers. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void Expire(string key, TimeSpan slidingExpiration)
    Parameters
    Type Name Description
    String key

    The cache key.

    TimeSpan slidingExpiration

    The expiration timeout. The value must be greater than zero.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    GetOrAdd(String, TCacheValue)

    Returns an existing item or adds the item to the cache if it does not exist. The method returns either the existing item's value or the newly added value.

    Declaration
    TCacheValue GetOrAdd(string key, TCacheValue value)
    Parameters
    Type Name Description
    String key

    The cache key.

    TCacheValue value

    The value which should be added.

    Returns
    Type Description
    TCacheValue

    Either the added or the existing value.

    Exceptions
    Type Condition
    ArgumentException

    If either key or value is null.

    | Improve this Doc View Source

    GetOrAdd(String, Func<String, TCacheValue>)

    Returns an existing item or adds the item to the cache if it does not exist. The valueFactory will be evaluated only if the item does not exist.

    Declaration
    TCacheValue GetOrAdd(string key, Func<string, TCacheValue> valueFactory)
    Parameters
    Type Name Description
    String key

    The cache key.

    Func<String, TCacheValue> valueFactory

    The method which creates the value which should be added.

    Returns
    Type Description
    TCacheValue

    Either the added or the existing value.

    Exceptions
    Type Condition
    ArgumentException

    If either key or valueFactory is null.

    | Improve this Doc View Source

    GetOrAdd(String, String, TCacheValue)

    Returns an existing item or adds the item to the cache if it does not exist. The method returns either the existing item's value or the newly added value.

    Declaration
    TCacheValue GetOrAdd(string key, string region, TCacheValue value)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    TCacheValue value

    The value which should be added.

    Returns
    Type Description
    TCacheValue

    Either the added or the existing value.

    Exceptions
    Type Condition
    ArgumentException

    If either key, region or value is null.

    | Improve this Doc View Source

    GetOrAdd(String, String, Func<String, String, TCacheValue>)

    Returns an existing item or adds the item to the cache if it does not exist. The valueFactory will be evaluated only if the item does not exist.

    Declaration
    TCacheValue GetOrAdd(string key, string region, Func<string, string, TCacheValue> valueFactory)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    Func<String, String, TCacheValue> valueFactory

    The method which creates the value which should be added.

    Returns
    Type Description
    TCacheValue

    Either the added or the existing value.

    Exceptions
    Type Condition
    ArgumentException

    If either key or valueFactory is null.

    | Improve this Doc View Source

    RemoveExpiration(String)

    Explicitly removes any expiration settings previously defined for the key in all cache layers and sets the expiration mode to None. This operation overrides any configured expiration per cache handle for this particular item.

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

    The cache key.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    RemoveExpiration(String, String)

    Explicitly removes any expiration settings previously defined for the key in region in all cache layers and sets the expiration mode to None. This operation overrides any configured expiration per cache handle for this particular item.

    Declaration
    void RemoveExpiration(string key, string region)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    Remarks

    Don't use this in concurrency critical scenarios if you are using distributed caches as

    Expire
    is not atomic;
    Expire
    uses Put(CacheItem<TCacheValue>) to store the item with the new expiration.

    | Improve this Doc View Source

    TryGetOrAdd(String, Func<String, TCacheValue>, out TCacheValue)

    Tries to either retrieve an existing item or add the item to the cache if it does not exist. The valueFactory will be evaluated only if the item does not exist.

    Declaration
    bool TryGetOrAdd(string key, Func<string, TCacheValue> valueFactory, out TCacheValue value)
    Parameters
    Type Name Description
    String key

    The cache key.

    Func<String, TCacheValue> valueFactory

    The method which creates the value which should be added.

    TCacheValue value

    The cache value.

    Returns
    Type Description
    Boolean

    True if the operation succeeds, False in case there are too many retries or the valueFactory returns null.

    Exceptions
    Type Condition
    ArgumentException

    If either key or valueFactory is null.

    | Improve this Doc View Source

    TryGetOrAdd(String, String, Func<String, String, TCacheValue>, out TCacheValue)

    Tries to either retrieve an existing item or add the item to the cache if it does not exist. The valueFactory will be evaluated only if the item does not exist.

    Declaration
    bool TryGetOrAdd(string key, string region, Func<string, string, TCacheValue> valueFactory, out TCacheValue value)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    Func<String, String, TCacheValue> valueFactory

    The method which creates the value which should be added.

    TCacheValue value

    The cache value.

    Returns
    Type Description
    Boolean

    True if the operation succeeds, False in case there are too many retries or the valueFactory returns null.

    Exceptions
    Type Condition
    ArgumentException

    If either key or valueFactory is null.

    | Improve this Doc View Source

    TryUpdate(String, Func<TCacheValue, TCacheValue>, out TCacheValue)

    Tries to update an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    bool TryUpdate(string key, Func<TCacheValue, TCacheValue> updateValue, out TCacheValue value)
    Parameters
    Type Name Description
    String key

    The key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    TCacheValue value

    The updated value, or null, if the update was not successful.

    Returns
    Type Description
    Boolean

    True if the update operation was successful, False otherwise.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or updateValue are null.

    | Improve this Doc View Source

    TryUpdate(String, Func<TCacheValue, TCacheValue>, Int32, out TCacheValue)

    Tries to update an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    bool TryUpdate(string key, Func<TCacheValue, TCacheValue> updateValue, int maxRetries, out TCacheValue value)
    Parameters
    Type Name Description
    String key

    The key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return False.

    TCacheValue value

    The updated value, or null, if the update was not successful.

    Returns
    Type Description
    Boolean

    True if the update operation was successful, False otherwise.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or updateValue is null.

    | Improve this Doc View Source

    TryUpdate(String, String, Func<TCacheValue, TCacheValue>, out TCacheValue)

    Tries to update an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    bool TryUpdate(string key, string region, Func<TCacheValue, TCacheValue> updateValue, out TCacheValue value)
    Parameters
    Type Name Description
    String key

    The key to update.

    String region

    The region of the key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    TCacheValue value

    The updated value, or null, if the update was not successful.

    Returns
    Type Description
    Boolean

    True if the update operation was successful, False otherwise.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or region or updateValue are null.

    | Improve this Doc View Source

    TryUpdate(String, String, Func<TCacheValue, TCacheValue>, Int32, out TCacheValue)

    Tries to update an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    bool TryUpdate(string key, string region, Func<TCacheValue, TCacheValue> updateValue, int maxRetries, out TCacheValue value)
    Parameters
    Type Name Description
    String key

    The key to update.

    String region

    The region of the key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return False.

    TCacheValue value

    The updated value, or null, if the update was not successful.

    Returns
    Type Description
    Boolean

    True if the update operation was successful, False otherwise.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or region or updateValue is null.

    | Improve this Doc View Source

    Update(String, Func<TCacheValue, TCacheValue>)

    Updates an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue Update(string key, Func<TCacheValue, TCacheValue> updateValue)
    Parameters
    Type Name Description
    String key

    The key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Returns
    Type Description
    TCacheValue

    The updated value, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or updateValue are null.

    | Improve this Doc View Source

    Update(String, Func<TCacheValue, TCacheValue>, Int32)

    Updates an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue Update(string key, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
    Parameters
    Type Name Description
    String key

    The key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return Null.

    Returns
    Type Description
    TCacheValue

    The updated value, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or updateValue is null.

    | Improve this Doc View Source

    Update(String, String, Func<TCacheValue, TCacheValue>)

    Updates an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue Update(string key, string region, Func<TCacheValue, TCacheValue> updateValue)
    Parameters
    Type Name Description
    String key

    The key to update.

    String region

    The region of the key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Returns
    Type Description
    TCacheValue

    The updated value, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or region or updateValue are null.

    | Improve this Doc View Source

    Update(String, String, Func<TCacheValue, TCacheValue>, Int32)

    Updates an existing key in the cache.

    The cache manager will make sure the update will always happen on the most recent version.

    If version conflicts occur, if for example multiple cache clients try to write the same key, and during the update process, someone else changed the value for the key, the cache manager will retry the operation.

    The updateValue function will get invoked on each retry with the most recent value which is stored in cache.

    Declaration
    TCacheValue Update(string key, string region, Func<TCacheValue, TCacheValue> updateValue, int maxRetries)
    Parameters
    Type Name Description
    String key

    The key to update.

    String region

    The region of the key to update.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Int32 maxRetries

    The number of tries which should be performed in case of version conflicts. If the cache cannot perform an update within the number of maxRetries, this method will return Null.

    Returns
    Type Description
    TCacheValue

    The updated value, or null, if the update was not successful.

    Remarks

    If the cache does not use a distributed cache system. Update is doing exactly the same as Get plus Put.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or region or updateValue is null.

    Events

    | Improve this Doc View Source

    OnAdd

    Occurs when an item was successfully added to the cache.

    The event will not get triggered if Add would return false.

    Declaration
    event EventHandler<CacheActionEventArgs> OnAdd
    Event Type
    Type Description
    EventHandler<CacheActionEventArgs>
    | Improve this Doc View Source

    OnClear

    Occurs when Clear gets called, after the cache has been cleared.

    Declaration
    event EventHandler<CacheClearEventArgs> OnClear
    Event Type
    Type Description
    EventHandler<CacheClearEventArgs>
    | Improve this Doc View Source

    OnClearRegion

    Occurs when ClearRegion gets called, after the cache region has been cleared.

    Declaration
    event EventHandler<CacheClearRegionEventArgs> OnClearRegion
    Event Type
    Type Description
    EventHandler<CacheClearRegionEventArgs>
    | Improve this Doc View Source

    OnGet

    Occurs when an item was retrieved from the cache.

    The event will only get triggered on cache hit. Misses do not trigger!

    Declaration
    event EventHandler<CacheActionEventArgs> OnGet
    Event Type
    Type Description
    EventHandler<CacheActionEventArgs>
    | Improve this Doc View Source

    OnPut

    Occurs when an item was put into the cache.

    Declaration
    event EventHandler<CacheActionEventArgs> OnPut
    Event Type
    Type Description
    EventHandler<CacheActionEventArgs>
    | Improve this Doc View Source

    OnRemove

    Occurs when an item was successfully removed from the cache.

    Declaration
    event EventHandler<CacheActionEventArgs> OnRemove
    Event Type
    Type Description
    EventHandler<CacheActionEventArgs>
    | Improve this Doc View Source

    OnRemoveByHandle

    Occurs when an item was removed by the cache handle due to expiration or e.g. memory pressure eviction. The Reason property indicates the reason while the Level indicates which handle triggered the event.

    Declaration
    event EventHandler<CacheItemRemovedEventArgs> OnRemoveByHandle
    Event Type
    Type Description
    EventHandler<CacheItemRemovedEventArgs>
    | Improve this Doc View Source

    OnUpdate

    Occurs when an item was successfully updated.

    Declaration
    event EventHandler<CacheActionEventArgs> OnUpdate
    Event Type
    Type Description
    EventHandler<CacheActionEventArgs>
    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net