@nowarajs/kv-store
    Preparing search index...

    Interface KvStore

    interface KvStore {
        clean(): number | Promise<number>;
        close?(): void | Promise<void>;
        connect?(): void | Promise<void>;
        decrement(key: string, amount?: number): number | Promise<number>;
        del(key: string): boolean | Promise<boolean>;
        expire(key: string, ttlSec: number): boolean | Promise<boolean>;
        get<T = unknown>(key: string): T | Promise<T | null> | null;
        increment(key: string, amount?: number): number | Promise<number>;
        set<T = unknown>(
            key: string,
            value: T,
            ttlSec?: number,
        ): void | Promise<void>;
        ttl(key: string): number | Promise<number>;
    }

    Implemented by

    Index

    Methods

    • Clean all keys from the store.

      Returns number | Promise<number>

      The number of keys that were removed.

    • Close the connection to the store.

      Returns void | Promise<void>

    • Connect to the store.

      Returns void | Promise<void>

    • Decrement the value associated with a key. Value needs to be a number.

      Parameters

      • key: string

        The key to decrement the value for.

      • Optionalamount: number

        The amount to decrement by.

      Returns number | Promise<number>

      The new value after decrementing.

    • Delete a key from the store.

      Parameters

      • key: string

        The key to delete.

      Returns boolean | Promise<boolean>

      true if the key was deleted, false otherwise.

    • Set the expiration time for a key.

      Parameters

      • key: string

        The key to set the expiration for.

      • ttlSec: number

        The time-to-live for the key, in seconds.

      Returns boolean | Promise<boolean>

      true if the expiration was set, false otherwise.

    • Get the value associated with a key.

      Type Parameters

      • T = unknown

        The type of the value to retrieve.

      Parameters

      • key: string

        The key to retrieve the value for.

      Returns T | Promise<T | null> | null

      The value associated with the key, or null if the key does not exist.

    • Increment the value associated with a key. Value needs to be a number.

      Parameters

      • key: string

        The key to increment the value for.

      • Optionalamount: number

        The amount to increment by.

      Returns number | Promise<number>

      The new value after incrementing.

    • Set the value associated with a key.

      Type Parameters

      • T = unknown

        The type of the value to set.

      Parameters

      • key: string

        The key to set the value for.

      • value: T

        The value to set.

      • OptionalttlSec: number

        The time-to-live for the key, in seconds.

      Returns void | Promise<void>

    • Get the remaining time-to-live for a key.

      Parameters

      • key: string

        The key to retrieve the TTL for.

      Returns number | Promise<number>

      The remaining time-to-live for the key, in seconds.