Base cache interface

Hierarchy (view full)

Constructors

  • Constructs a new instance of a memory-based cache

    Parameters

    • options: Partial<Options> = {}

    Returns Memory

Properties

client: NodeCache
defaultTTL: 300 = 300

Accessors

  • get isReady(): Readonly<boolean>
  • Returns in the instance is ready

    Returns Readonly<boolean>

  • get type(): string
  • Returns string

Methods

  • Deletes all keys (and values) from the cache

    Returns Promise<boolean>

  • Connects to the memory storage

    Returns Promise<void>

  • Deletes the key (including the value) from the cache

    Type Parameters

    • KeyType = any

    Parameters

    Returns Promise<number>

  • Closes the storage connection and halts the check interval

    Returns Promise<void>

  • Retrieves the current TTL of the specified key

    Type Parameters

    • KeyType = any

    Parameters

    Returns Promise<undefined | number>

  • Checks if the specified key exists in the cache

    Type Parameters

    • KeyType = any

    Parameters

    Returns Promise<boolean>

  • Mass deletes values with the specified keys

    Type Parameters

    • KeyType = any

    Parameters

    Returns Promise<number>

  • Mass sets values with the specified keys

    Type Parameters

    • ValueType = any
    • KeyType = any

    Parameters

    Returns Promise<boolean>

  • Parameters

    • event: "set"
    • listener: ((key, value) => void)
        • (key, value): void
        • Parameters

          • key: any
          • value: any

          Returns void

    Returns this

  • Parameters

    • event: "expired"
    • listener: ((key, value) => void)
        • (key, value): void
        • Parameters

          • key: any
          • value: any

          Returns void

    Returns this

  • Parameters

    • event: "del"
    • listener: ((key, value) => void)
        • (key, value): void
        • Parameters

          • key: any
          • value: any

          Returns void

    Returns this

  • Parameters

    • event: "flush"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "flush_stats"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "error"
    • listener: ((error) => void)
        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns this

  • Sets the value for the specified key

    Type Parameters

    • ValueType = any
    • KeyType = any

    Parameters

    Returns Promise<boolean>

  • Retrieves the value of the specified key and immediately deletes it from the cache

    Type Parameters

    • ValueType = any
    • KeyType = any

    Parameters

    Returns Promise<undefined | ValueType>

  • Updates the TTL for the specified key

    Type Parameters

    • KeyType = any

    Parameters

    Returns Promise<boolean>