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

    Class BaseCacheHandle<TCacheValue>

    The BaseCacheHandle implements all the logic which might be common for all the cache handles. It abstracts the ICache<TCacheValue> interface and defines new properties and methods the implementer must use.

    Actually it is not advisable to not use BaseCacheHandle<TCacheValue>.

    Inheritance
    Object
    BaseCache<TCacheValue>
    BaseCacheHandle<TCacheValue>
    DictionaryCacheHandle<TCacheValue>
    BucketCacheHandle<TCacheValue>
    MemcachedCacheHandle<TCacheValue>
    MemoryCacheHandle<TCacheValue>
    RedisCacheHandle<TCacheValue>
    MemoryCacheHandle<TCacheValue>
    SystemWebCacheHandle<TCacheValue>
    Inherited Members
    BaseCache<TCacheValue>.Logger
    BaseCache<TCacheValue>.Disposed
    BaseCache<TCacheValue>.Disposing
    BaseCache<TCacheValue>.Item[String]
    BaseCache<TCacheValue>.Item[String, String]
    BaseCache<TCacheValue>.Add(String, TCacheValue)
    BaseCache<TCacheValue>.Add(String, TCacheValue, String)
    BaseCache<TCacheValue>.Add(CacheItem<TCacheValue>)
    BaseCache<TCacheValue>.Clear()
    BaseCache<TCacheValue>.ClearRegion(String)
    BaseCache<TCacheValue>.Dispose()
    BaseCache<TCacheValue>.Exists(String)
    BaseCache<TCacheValue>.Exists(String, String)
    BaseCache<TCacheValue>.Get(String)
    BaseCache<TCacheValue>.Get(String, String)
    BaseCache<TCacheValue>.Get<TOut>(String)
    BaseCache<TCacheValue>.Get<TOut>(String, String)
    BaseCache<TCacheValue>.GetCacheItem(String)
    BaseCache<TCacheValue>.GetCacheItem(String, String)
    BaseCache<TCacheValue>.Put(String, TCacheValue)
    BaseCache<TCacheValue>.Put(String, TCacheValue, String)
    BaseCache<TCacheValue>.Put(CacheItem<TCacheValue>)
    BaseCache<TCacheValue>.Remove(String)
    BaseCache<TCacheValue>.Remove(String, String)
    BaseCache<TCacheValue>.GetCacheItemInternal(String)
    BaseCache<TCacheValue>.GetCacheItemInternal(String, String)
    BaseCache<TCacheValue>.RemoveInternal(String)
    BaseCache<TCacheValue>.RemoveInternal(String, String)
    BaseCache<TCacheValue>.CheckDisposed()
    BaseCache<TCacheValue>.GetCasted<TOut>(Object)
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace:CacheManager.Core.Internal
    Assembly:CacheManager.Core.dll
    Syntax
    public abstract class BaseCacheHandle<TCacheValue> : BaseCache<TCacheValue>, ICache<TCacheValue>, IDisposable
    Type Parameters
    Name Description
    TCacheValue

    The type of the cache value.

    Constructors

    | Improve this Doc View Source

    BaseCacheHandle(ICacheManagerConfiguration, CacheHandleConfiguration)

    Initializes a new instance of the BaseCacheHandle<TCacheValue> class.

    Declaration
    protected BaseCacheHandle(ICacheManagerConfiguration managerConfiguration, CacheHandleConfiguration configuration)
    Parameters
    Type Name Description
    ICacheManagerConfiguration managerConfiguration

    The manager's configuration.

    CacheHandleConfiguration configuration

    The configuration.

    Exceptions
    Type Condition
    ArgumentNullException

    If managerConfiguration or configuration are null.

    ArgumentException

    If configuration name is empty.

    Properties

    | Improve this Doc View Source

    Configuration

    Gets the cache handle configuration.

    Declaration
    public CacheHandleConfiguration Configuration { get; }
    Property Value
    Type Description
    CacheHandleConfiguration

    The configuration.

    | Improve this Doc View Source

    Count

    Gets the number of items the cache handle currently maintains.

    Declaration
    public abstract int Count { get; }
    Property Value
    Type Description
    Int32

    The count.

    | Improve this Doc View Source

    IsDistributedCache

    Indicates if this cache handle is a distributed cache.

    Declaration
    public virtual bool IsDistributedCache { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    The value will be evaluated by the backplane logic to figure out what to do if remote events are received.

    If the cache handle is distributed, a remote remove event for example does not cause another Remove call. For in-memory cache handles which are backplane source though, it would trigger a Remove.

    | Improve this Doc View Source

    Stats

    Gets the cache stats object.

    Declaration
    public virtual CacheStats<TCacheValue> Stats { get; }
    Property Value
    Type Description
    CacheStats<TCacheValue>

    The stats.

    Methods

    | Improve this Doc View Source

    AddInternal(CacheItem<TCacheValue>)

    Adds a value to the cache.

    Declaration
    protected override bool AddInternal(CacheItem<TCacheValue> item)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> item

    The CacheItem to be added to the cache.

    Returns
    Type Description
    Boolean

    true if the key was not already added to the cache, false otherwise.

    Overrides
    CacheManager.Core.Internal.BaseCache<TCacheValue>.AddInternal(CacheManager.Core.CacheItem<TCacheValue>)
    | Improve this Doc View Source

    AddInternalPrepared(CacheItem<TCacheValue>)

    Adds a value to the cache.

    Declaration
    protected abstract bool AddInternalPrepared(CacheItem<TCacheValue> item)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> item

    The CacheItem to be added to the cache.

    Returns
    Type Description
    Boolean

    true if the key was not already added to the cache, false otherwise.

    | Improve this Doc View Source

    Dispose(Boolean)

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    protected override void Dispose(bool disposeManaged)
    Parameters
    Type Name Description
    Boolean disposeManaged

    Indicator if managed resources should be released.

    Overrides
    CacheManager.Core.Internal.BaseCache<TCacheValue>.Dispose(System.Boolean)
    | Improve this Doc View Source

    GetItemExpiration(CacheItem<TCacheValue>)

    Gets the item expiration.

    Declaration
    protected virtual CacheItem<TCacheValue> GetItemExpiration(CacheItem<TCacheValue> item)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> item

    The item.

    Returns
    Type Description
    CacheItem<TCacheValue>

    Returns the updated cache item.

    Exceptions
    Type Condition
    ArgumentNullException

    If item is null.

    InvalidOperationException

    If expiration mode is defined without timeout.

    | Improve this Doc View Source

    PutInternal(CacheItem<TCacheValue>)

    Puts the item into the cache. If the item exists it will get updated with the new value. If the item doesn't exist, the item will be added to the cache.

    Declaration
    protected override void PutInternal(CacheItem<TCacheValue> item)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> item

    The CacheItem to be added to the cache.

    Overrides
    CacheManager.Core.Internal.BaseCache<TCacheValue>.PutInternal(CacheManager.Core.CacheItem<TCacheValue>)
    | Improve this Doc View Source

    PutInternalPrepared(CacheItem<TCacheValue>)

    Puts the item into the cache. If the item exists it will get updated with the new value. If the item doesn't exist, the item will be added to the cache.

    Declaration
    protected abstract void PutInternalPrepared(CacheItem<TCacheValue> item)
    Parameters
    Type Name Description
    CacheItem<TCacheValue> item

    The CacheItem to be added to the cache.

    | Improve this Doc View Source

    TriggerCacheSpecificRemove(String, String, CacheItemRemovedReason, Object)

    Can be used to signal a remove event to the ICacheManager<TCacheValue> in case the underlying cache supports this and the implementation can react on evictions and expiration of cache items.

    Declaration
    protected void TriggerCacheSpecificRemove(string key, string region, CacheItemRemovedReason reason, object value)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region. Can be null.

    CacheItemRemovedReason reason

    The reason.

    Object value

    The original cache value. The value might be null if the underlying cache system doesn't support returning the value on eviction.

    Exceptions
    Type Condition
    ArgumentNullException

    If key is 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
    public virtual UpdateItemResult<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.

    Returns
    Type Description
    UpdateItemResult<TCacheValue>

    The update result which is interpreted by the cache manager.

    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>, 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
    public virtual UpdateItemResult<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 cache region.

    Func<TCacheValue, TCacheValue> updateValue

    The function to perform the update.

    Int32 maxRetries

    The number of tries.

    Returns
    Type Description
    UpdateItemResult<TCacheValue>

    The update result which is interpreted by the cache manager.

    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, region or updateValue is null.

    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net