Options
All
  • Public
  • Public/Protected
  • All
Menu

API for a synchronous storage

Hierarchy

Index

Methods

  • clear<T>(filter?: ClearFilter<T>, ...args: unknown[]): void
  • Clears the storage by the specified filter and returns a list of removed keys. Notice, the method can take a list of additional parameters provided to the used storage' engine.

    Type parameters

    • T = unknown

    Parameters

    Returns void

  • get<T>(key: string, ...args: unknown[]): CanUndef<T>
  • Returns a value from the storage by the specified key.

    The returning value automatically parses by using Object.parse from a string to equivalent JS value, i.e., '1' will be parsed to 1, 'true' to true, '2021-07-09T08:15:57.753Z' to Date, etc.

    Notice, the method can take a list of additional parameters provided to the used storage' engine.

    Type parameters

    • T = unknown

    Parameters

    • key: string
    • Rest ...args: unknown[]

    Returns CanUndef<T>

  • has(key: string, ...args: unknown[]): boolean
  • Returns true if a value by the specified key exists in the storage. Notice, the method can take a list of additional parameters provided to the used storage' engine.

    Parameters

    • key: string
    • Rest ...args: unknown[]

    Returns boolean

  • remove(key: string, ...args: unknown[]): void
  • set(key: string, value: unknown, ...args: unknown[]): void
  • Saves a value to the storage by the specified key.

    The value to parse automatically serializes to a string by using Object.trySerialize, i.e., arrays and dictionaries will be serialized to JSON, etc.

    Notice, the method can take a list of additional parameters provided to the used storage' engine.

    Parameters

    • key: string
    • value: unknown
    • Rest ...args: unknown[]

    Returns void