Class LazyStorage

Hierarchy

  • EventEmitter
    • LazyStorage

Constructors

  • Parameters

    • Optional options: Options

    Returns LazyStorage

Methods

  • Alias for flushAll()

    Returns void

  • Closes the storage and halts the check interval

    Returns void

  • Deletes the value(s) with the specified key

    Type Parameters

    • KeyType = any

    Parameters

    • key: KeyType

    Returns number

  • Flushes all records from storage

    Returns void

  • Flushes the storage statistics

    Returns void

  • Retrieves the value with the given key

    Type Parameters

    • ValueType = any

    • KeyType = any

    Parameters

    • key: KeyType

    Returns undefined | ValueType

  • Retrieves the current ttl of the specified key

    Type Parameters

    • KeyType = any

    Parameters

    • key: KeyType

    Returns undefined | number

  • Checks if the given key exists

    Type Parameters

    • KeyType = any

    Parameters

    • key: KeyType

    Returns boolean

  • Retrieves a list of all keys

    Type Parameters

    • KeyType = any

    Returns KeyType[]

  • Retrieves a map of all keys and values

    Type Parameters

    • ValueType = any

    • KeyType = any

    Returns Map<KeyType, ValueType>

  • Mass deletes values with the specified keys

    Type Parameters

    • KeyType = any

    Parameters

    • keys: KeyType[]

    Returns number

  • Mass retrieves values with the specified keys

    Type Parameters

    • ValueType = any

    • KeyType = any

    Parameters

    • keys: KeyType[]

    Returns Map<KeyType, ValueType>

  • Mass sets values with the specified keys

    Type Parameters

    • ValueType = any

    • KeyType = any

    Parameters

    • keys: KeyType[]
    • values: ValueType[]
    • ttl: number = ...

    Returns boolean

  • Parameters

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

          • key: any
          • value: any

          Returns void

    Returns LazyStorage

  • Parameters

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

          • key: any
          • value: any

          Returns void

    Returns LazyStorage

  • Parameters

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

          • key: any
          • value: any

          Returns void

    Returns LazyStorage

  • Parameters

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

    Returns LazyStorage

  • Parameters

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

    Returns LazyStorage

  • Parameters

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

          • error: Error

          Returns void

    Returns LazyStorage

  • Alias for del()

    Type Parameters

    • KeyType = any

    Parameters

    • key: KeyType

    Returns number

  • Sets the value for the specified key

    Type Parameters

    • ValueType = any

    • KeyType = any

    Parameters

    • key: KeyType
    • value: ValueType
    • ttl: number = ...

    Returns boolean

  • Returns storage statistics

    Returns {
        hits: number;
        keys: number;
        ksize: number;
        misses: number;
        vsize: number;
    }

    • hits: number
    • keys: number
    • ksize: number
    • misses: number
    • vsize: number
  • Retrieves the value with the specified key and immediately deletes it from storage

    Type Parameters

    • ValueType = any

    • KeyType = any

    Parameters

    • key: KeyType

    Returns undefined | ValueType

  • Updates the ttl for the specified key

    Type Parameters

    • KeyType = any

    Parameters

    • key: KeyType
    • ttl: number = ...

    Returns boolean