Options
All
  • Public
  • Public/Protected
  • All
Menu

TTL (Time to Life) Map

it will lazy remove values when perform operations

since

5.18.0

Type parameters

  • K = any

  • V = any

Hierarchy

Index

Constructors

  • new TTLMap<K, V>(defaultTTL?: number, cleanAfterOperation?: number): TTLMap<K, V>
  • TTLMap (Time to Life) Map

    it will lazy remove values when perform operations

    Type parameters

    • K = any

    • V = any

    Parameters

    • defaultTTL: number = ...

      time to live, in milliseconds, default value is 60 seconds

    • cleanAfterOperation: number = 100

      execute full clean after operations. default value is 100, it means, at least 100 operations performed, the TTL evict logic will be executed

    Returns TTLMap<K, V>

Properties

[toStringTag]: string
[species]: MapConstructor

Accessors

  • get size(): number
  • Returns number

Methods

  • [iterator](): IterableIterator<[K, V]>
  • Returns an iterable of entries in the map.

    Returns IterableIterator<[K, V]>

  • cleanTimeoutItems(): void
  • manually directly clean all timeout items

    Returns void

  • clear(): void
  • Returns void

  • delete(k: K): boolean
  • Parameters

    • k: K

    Returns boolean

  • entries(): IterableIterator<[K, V]>
  • Returns IterableIterator<[K, V]>

  • forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void
  • Parameters

    • callbackfn: (value: V, key: K, map: Map<K, V>) => void
        • (value: V, key: K, map: Map<K, V>): void
        • Parameters

          • value: V
          • key: K
          • map: Map<K, V>

          Returns void

    • Optional thisArg: any

    Returns void

  • get(k: K): V
  • Parameters

    • k: K

    Returns V

  • has(k: K): boolean
  • Parameters

    • k: K

    Returns boolean

  • keys(): IterableIterator<K>
  • Returns IterableIterator<K>

  • set(k: K, v: V, ttl?: number): TTLMap<K, V>
  • set value

    Parameters

    • k: K

      key

    • v: V

      value

    • ttl: number = ...

      time to live, in milliseconds, if undefined, will use instance level defaultTTL

    Returns TTLMap<K, V>

  • values(): IterableIterator<V>
  • Returns IterableIterator<V>