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

    Class CacheItem<T>

    The item which will be stored in the cache holding the cache value and additional information needed by the cache handles and manager.

    Inheritance
    Object
    CacheItem<T>
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace:CacheManager.Core
    Assembly:CacheManager.Core.dll
    Syntax
    [Serializable]
    public class CacheItem<T> : ISerializable, ICacheItemProperties
    Type Parameters
    Name Description
    T

    The type of the cache value.

    Constructors

    | Improve this Doc View Source

    CacheItem()

    Initializes a new instance of the CacheItem<T> class.

    Declaration
    protected CacheItem()
    | Improve this Doc View Source

    CacheItem(SerializationInfo, StreamingContext)

    Initializes a new instance of the CacheItem<T> class.

    Declaration
    protected CacheItem(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    SerializationInfo info

    The information.

    StreamingContext context

    The context.

    Exceptions
    Type Condition
    ArgumentNullException

    If info is null.

    | Improve this Doc View Source

    CacheItem(String, T)

    Initializes a new instance of the CacheItem<T> class.

    Declaration
    public CacheItem(string key, T value)
    Parameters
    Type Name Description
    String key

    The cache key.

    T value

    The cache value.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or value are null.

    | Improve this Doc View Source

    CacheItem(String, T, ExpirationMode, TimeSpan)

    Initializes a new instance of the CacheItem<T> class.

    Declaration
    public CacheItem(string key, T value, ExpirationMode expiration, TimeSpan timeout)
    Parameters
    Type Name Description
    String key

    The cache key.

    T value

    The cache value.

    ExpirationMode expiration

    The expiration mode.

    TimeSpan timeout

    The expiration timeout.

    Exceptions
    Type Condition
    ArgumentNullException

    If key or value are null.

    | Improve this Doc View Source

    CacheItem(String, String, T)

    Initializes a new instance of the CacheItem<T> class.

    Declaration
    public CacheItem(string key, string region, T value)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    T value

    The cache value.

    Exceptions
    Type Condition
    ArgumentNullException

    If key, value or region are null.

    | Improve this Doc View Source

    CacheItem(String, String, T, ExpirationMode, TimeSpan)

    Initializes a new instance of the CacheItem<T> class.

    Declaration
    public CacheItem(string key, string region, T value, ExpirationMode expiration, TimeSpan timeout)
    Parameters
    Type Name Description
    String key

    The cache key.

    String region

    The cache region.

    T value

    The cache value.

    ExpirationMode expiration

    The expiration mode.

    TimeSpan timeout

    The expiration timeout.

    Exceptions
    Type Condition
    ArgumentNullException

    If key, value or region are null.

    Properties

    | Improve this Doc View Source

    CreatedUtc

    Gets the creation date of the cache item.

    Declaration
    public DateTime CreatedUtc { get; }
    Property Value
    Type Description
    DateTime

    The creation date.

    Implements
    ICacheItemProperties.CreatedUtc
    | Improve this Doc View Source

    ExpirationMode

    Gets the expiration mode.

    Declaration
    public ExpirationMode ExpirationMode { get; }
    Property Value
    Type Description
    ExpirationMode

    The expiration mode.

    Implements
    ICacheItemProperties.ExpirationMode
    | Improve this Doc View Source

    ExpirationTimeout

    Gets the expiration timeout.

    Declaration
    public TimeSpan ExpirationTimeout { get; }
    Property Value
    Type Description
    TimeSpan

    The expiration timeout.

    Implements
    ICacheItemProperties.ExpirationTimeout
    | Improve this Doc View Source

    IsExpired

    Gets a value indicating whether the item is logically expired or not. Depending on the cache vendor, the item might still live in the cache although according to the expiration mode and timeout, the item is already expired.

    Declaration
    public bool IsExpired { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    Key

    Gets the cache key.

    Declaration
    public string Key { get; }
    Property Value
    Type Description
    String

    The cache key.

    Implements
    ICacheItemProperties.Key
    | Improve this Doc View Source

    LastAccessedUtc

    Gets or sets the last accessed date of the cache item.

    Declaration
    public DateTime LastAccessedUtc { get; set; }
    Property Value
    Type Description
    DateTime

    The last accessed date.

    Implements
    ICacheItemProperties.LastAccessedUtc
    | Improve this Doc View Source

    Region

    Gets the cache region.

    Declaration
    public string Region { get; }
    Property Value
    Type Description
    String

    The cache region.

    Implements
    ICacheItemProperties.Region
    | Improve this Doc View Source

    UsesExpirationDefaults

    Gets a value indicating whether the cache item uses the cache handle's configured expiration.

    Declaration
    public bool UsesExpirationDefaults { get; }
    Property Value
    Type Description
    Boolean
    Implements
    ICacheItemProperties.UsesExpirationDefaults
    | Improve this Doc View Source

    Value

    Gets the cache value.

    Declaration
    public T Value { get; }
    Property Value
    Type Description
    T

    The cache value.

    | Improve this Doc View Source

    ValueType

    Gets the type of the cache value.

    This might be used for serialization and deserialization.

    Declaration
    public Type ValueType { get; }
    Property Value
    Type Description
    Type

    The type of the cache value.

    Implements
    ICacheItemProperties.ValueType

    Methods

    | Improve this Doc View Source

    GetObjectData(SerializationInfo, StreamingContext)

    Populates a SerializationInfo with the data needed to serialize the target object.

    Declaration
    public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    SerializationInfo info

    The SerializationInfo to populate with data.

    StreamingContext context

    The destination (see StreamingContext) for this serialization.

    Implements
    ISerializable.GetObjectData(SerializationInfo, StreamingContext)
    Exceptions
    Type Condition
    ArgumentNullException

    If info is null.

    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Object.ToString()
    | Improve this Doc View Source

    WithAbsoluteExpiration(DateTimeOffset)

    Creates a copy of the current cache item and sets a new absolute expiration date. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithAbsoluteExpiration(DateTimeOffset absoluteExpiration)
    Parameters
    Type Name Description
    DateTimeOffset absoluteExpiration

    The absolute expiration date.

    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

    | Improve this Doc View Source

    WithAbsoluteExpiration(TimeSpan)

    Creates a copy of the current cache item and sets a new absolute expiration date. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithAbsoluteExpiration(TimeSpan absoluteExpiration)
    Parameters
    Type Name Description
    TimeSpan absoluteExpiration

    The absolute expiration date.

    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

    | Improve this Doc View Source

    WithCreated(DateTime)

    Creates a copy of the current cache item with a given created date. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithCreated(DateTime created)
    Parameters
    Type Name Description
    DateTime created

    The new created date.

    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

    | Improve this Doc View Source

    WithDefaultExpiration()

    Creates a copy of the current cache item with no explicit expiration, instructing the cache to use the default defined in the cache handle configuration. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithDefaultExpiration()
    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

    | Improve this Doc View Source

    WithNoExpiration()

    Creates a copy of the current cache item without expiration. Can be used to update the cache and remove any previously configured expiration of the item. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithNoExpiration()
    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

    | Improve this Doc View Source

    WithSlidingExpiration(TimeSpan)

    Creates a copy of the current cache item and sets a new sliding expiration value. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithSlidingExpiration(TimeSpan slidingExpiration)
    Parameters
    Type Name Description
    TimeSpan slidingExpiration

    The sliding expiration value.

    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

    | Improve this Doc View Source

    WithValue(T)

    Creates a copy of the current cache item with new value. This method doesn't change the state of the item in the cache. Use Put or similar methods to update the cache with the returned copy of the item.

    Declaration
    public CacheItem<T> WithValue(T value)
    Parameters
    Type Name Description
    T value

    The new value.

    Returns
    Type Description
    CacheItem<T>

    The new instance of the cache item.

    Remarks

    We do not clone the cache item or value.

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