Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AdequateCache<TValue, TProviderArgs>

Entirely adequate node.js in-memory cache with lru and ttl support

Type parameters

  • TValue

  • TProviderArgs: any[] = any[]

Hierarchy

  • AdequateCache

Index

Constructors

constructor

Methods

del

  • del(key: string | number): boolean
  • Delete value at key. Returns true if value was in the cache, false if not.

    Parameters

    • key: string | number

    Returns boolean

emptyOut

  • emptyOut(): void

get

  • get(key: string | number): TValue
  • Get value at key, or return undefined

    Parameters

    • key: string | number

    Returns TValue

has

  • has(key: string | number): boolean
  • Returns true if cache contains value at given key. Note that there is no performance benefit to calling this over get(), it's just a convenience method.

    Parameters

    • key: string | number

    Returns boolean

keys

  • keys(): IterableIterator<string>
  • Returns an iterator of all the keys currently in cache. Performs vacuum beforehand, so the keys you get are guaranteed to be actually non-expired. Keys are provided converted to string.

    Returns IterableIterator<string>

provide

  • provide(...args: TProviderArgs): Promise<TValue>
  • Returns value if it is already in cache. Otherwise, calls the "provider" method (that must be given through options) and stores the value in cache, before returning it.

    Parameters

    • Rest ...args: TProviderArgs

    Returns Promise<TValue>

set

  • set(key: string | number, value: TValue, ttl?: number): boolean
  • Set value at key. Optionally set ttl for this particular key, otherwise use the global default. If value is undefined, the key is deleted from cache.

    Parameters

    • key: string | number
    • value: TValue
    • Optional ttl: number

      Set TTL specifically for this key

    Returns boolean

Generated using TypeDoc