Represents a generic cache object with a unique identifier, data, a calculated checksum, validity period, and a defined lifetime.

This class provides functionality to initialize, update, and manage cached data, including recalculating a checksum for integrity and setting header information for external use.

Type Parameters

  • T = any

    The type of data stored in the cache.

Constructors

Properties

Methods

Constructors

  • Constructs a new instance of the cache-like object with the given properties.

    Type Parameters

    • T = any

    Parameters

    • cacheLike: { data: T; id: string; lifeTime: TimeSpan }

      The cache-like object containing initialization properties.

      • data: T

        The data to be stored in the cache object.

      • id: string

        The unique identifier for the cache object.

      • lifeTime: TimeSpan

        The lifespan of the cache object.

    Returns Cache<T>

Properties

checksum: string
data: T
id: string
validUntil: DateTime

Methods

  • Retrieves the headers as an object where keys represent the header names and values represent their respective values.

    Returns { [key: string]: string }

    An object containing header key-value pairs. Specifically includes the 'X-Cache-Checksum' header and its value.