Class Cache<Type, Ready>

Type Parameters

  • Type

  • Ready extends boolean = false

Hierarchy

  • Cache

Implements

Constructors

  • Type Parameters

    • Type

    • Ready extends boolean = false

    Parameters

    Returns Cache<Type, Ready>

Properties

[toStringTag]: "Cache"
max_size: number
query: QueryBind<Key>

Utility to query through map keys

ready: Ready

Cache is ready to use

size: number

Exposes Store.query

Methods

  • Returns IterableIterator<[Key, Type]>

  • Returns void

  • Parameters

    • key: Key
    • Optional include_store: boolean

      delete key in store

    Returns Promise<boolean>

    deleted_from_map || (include_store && deleted_from_store)

  • Returns IterableIterator<[Key, Type]>

  • Insert all items into the store, then clear the cache.

    Returns Promise<void>

  • Parameters

    • callbackfn: ((value, key, map) => void)
        • (value, key, map): void
        • Parameters

          • value: Type
          • key: Key
          • map: Map<Key, Type>

          Returns void

    • Optional thisArg: any

    Returns void

  • Get value by key.

    Parameters

    • key: Key
    • Optional include_store: boolean

      if key is not found in the cache, then search the store. If found in the store, automatically load it into the cache.

    Returns Promise<NullableCacheValue<Type>>

  • Get key metadata. Only works if key has already been stored at some point.

    Parameters

    Returns Promise<undefined | Metadata>

  • Parameters

    • key: Key
    • Optional include_store: boolean

      if key is not found in the cache, then search the store.

    Returns boolean

  • Returns IterableIterator<Key>

  • Load items from the store, in reverse chronological order, limited by max_size.

    Returns Promise<void>

  • Insert items into the store.

    Parameters

    • keys: "all" | Key[]

    Returns Promise<void>

  • Adds a new element with a specified key and value to the Cache. If an element with the same key already exists, the element will be updated. If the insertion of the element makes the cache larger than max_size, the first pushed element is flushed to store. If a string key is passed, a new Key instance will be generated.

    Parameters

    • key: string | Key
    • value: Type

    Returns Promise<Key>

  • Returns IterableIterator<Type>

  • Type Parameters

    • Type

    Parameters

    • args: {
          store: {
              clean?: boolean;
              dest: string;
          };
      } & Omit<NewCacheArgs<Type, boolean>, "store">

    Returns Promise<Cache<Type, true>>

Generated using TypeDoc