A simple in-memory cache that stores data in a Map.

The default cache is a simple map that stores domain/record type pairs as keys and the corresponding data as values.

The cache makes no attempt to implement an LRU eviction policy, as these can be computationally expensive to manage and may not necessarily provide a significant benefit over a simple random eviction policy. Domains that are queried often will naturally get inserted into the cache quickly after being evicted.

Hierarchy (view full)

Constructors

Properties

cache: Map<string, (
    | CaaData
    | DnskeyData
    | DsData
    | HInfoData
    | MxData
    | NaptrData
    | NsecData
    | Nsec3Data
    | RpData
    | RrsigData
    | SrvData
    | SoaData
    | SshfpData
    | TlsaData
    | TxtData)[]> = ...

The internal cache data structure

handler: Handler = ...

The cache handler function that is used to answer queries.

maxEntries: undefined | number

The maximum number of entries the cache should accept before discarding an entry.

Accessors

  • get size(): number
  • Get the current size of the cache.

    Note that this refers to the number of unique zone/record type pairs in the cache, not the total number of records stored, as each zone/record type pair can store one or more records.

    Returns number

    The number of unique zone/record type pairs in the cache.

Methods

  • Append information about a zone in the cache.

    Parameters

    • zone: string

      The zone to append

    • rType: SupportedRecordType

      The record type to append

    • data:
          | CaaData
          | DnskeyData
          | DsData
          | HInfoData
          | MxData
          | NaptrData
          | NsecData
          | Nsec3Data
          | RpData
          | RrsigData
          | SrvData
          | SoaData
          | SshfpData
          | TlsaData
          | TxtData

      The data to append

    Returns void

  • Delete information about a zone in the cache.

    Parameters

    • zone: string

      The zone to delete

    • rType: SupportedRecordType

      The record type to delete

    • Optionaldata:
          | CaaData
          | DnskeyData
          | DsData
          | HInfoData
          | MxData
          | NaptrData
          | NsecData
          | Nsec3Data
          | RpData
          | RrsigData
          | SrvData
          | SoaData
          | SshfpData
          | TlsaData
          | TxtData

      The data to delete

    Returns void

  • Get information about a zone/record type pair in the cache.

    Type Parameters

    Parameters

    • zone: string

      The zone to get data for

    • rType: T

      The record type to get data for.

    Returns null | (
        | CaaData
        | DnskeyData
        | DsData
        | HInfoData
        | MxData
        | NaptrData
        | NsecData
        | Nsec3Data
        | RpData
        | RrsigData
        | SrvData
        | SoaData
        | SshfpData
        | TlsaData
        | TxtData)[] | ZoneData[T][]

    The data for the given zone and record type, or null if no data is found.

  • Set or update information about a zone in the cache.

    Type Parameters

    Parameters

    • zone: string

      The zone to set

    • rType: T

      The record type to set

    • data: (
          | CaaData
          | DnskeyData
          | DsData
          | HInfoData
          | MxData
          | NaptrData
          | NsecData
          | Nsec3Data
          | RpData
          | RrsigData
          | SrvData
          | SoaData
          | SshfpData
          | TlsaData
          | TxtData)[] | ZoneData[T]

      The data to set

    Returns void