The cache.

Implements

Constructors

Properties

isMemoryUsage: true = ...

Readonly flag to indicate that his object implements MemoryUsage.

Accessors

  • get capacity(): number
  • Gets the maximum number of entries.

    Returns number

  • get count(): number
  • Gets the number of entries.

    Returns number

  • get defaultTtl(): number
  • Gets or sets the default TTL (time to live) of the cache.

    Returns number

  • set defaultTtl(v): void
  • Parameters

    • v: number

    Returns void

  • get enabled(): boolean
  • Enables or disables the cache.

    Returns boolean

  • set enabled(v): void
  • Parameters

    • v: boolean

    Returns void

  • get maxSize(): number
  • Gets the maximum size of the cache, in bytes.

    Returns number

  • get size(): number
  • Gets the size of entries, in bytes

    Returns number

Methods

  • Configure the cache with the specified configuration. The cache must be empty otherwise this method will throw an error.

    Parameters

    Returns void

  • Deletes an entry.

    Parameters

    • key: string

      The key.

    Returns boolean

    true if the entry was deleted, false otherwise.

  • Returns an array of entries.

    Returns unknown[]

  • Returns the entry with the specified key, or undefined if no entry matches this key.

    Parameters

    • key: string

      The entry key.

    Returns unknown

    The entry, or undefined.

  • Stores an entry in the cache, or replaces an existing entry with the same key.

    Type Parameters

    • T extends object

    Parameters

    • key: string

      The key.

    • value: T

      The value.

    • options: CacheOptions = {}

      The options.

    Returns T