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

    Class MemoryStore

    In-memory key-value store implementation with automatic cleanup of expired entries.

    Provides a memory-based implementation of the KvStore interface with TTL support and automatic background cleanup of expired entries.

    Implements

    Index

    Constructors

    Methods

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

      Parameters

      • key: string

        The key to decrement the value for.

      • amount: number = 1

        The amount to decrement by.

      Returns number

      The new value after decrementing.

    • Delete a key from the store.

      Parameters

      • key: string

        The key to delete.

      Returns 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

      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 | 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.

      • amount: number = 1

        The amount to increment by.

      Returns 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

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

      Parameters

      • key: string

        The key to retrieve the TTL for.

      Returns number

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