Dalmart
    Preparing search index...

    Interface IZDatabaseMemory

    Represents a set of database operations for an in-memory database.

    These kinds of databases are key value pairs similar to redis, local storage, sessions storage, etc.

    interface IZDatabaseMemory {
        delete(key?: string): Promise<void>;
        read<T>(key: string): Promise<null | T>;
        read<T>(key: string, fallback: T): Promise<T>;
        upsert<T>(key: string, value: T): Promise<T>;
    }

    Implemented by

    Index

    Methods

    • Deletes a key in the database or deletes all keys in the database.

      Parameters

      • Optionalkey: string

        The key to delete. If this is undefined, then all keys should be deleted.

      Returns Promise<void>

    • Gets the value of a specific key in the database.

      Type Parameters

      • T

      Parameters

      • key: string

        The key to retrieve.

      Returns Promise<null | T>

      The value of the given key, null if no such value exists and no fallback was provided.

    • Gets the value of a specific key in the database.

      Type Parameters

      • T

      Parameters

      • key: string

        The key to retrieve.

      • fallback: T

        The fallback value. If the key does not exist in the database, then this will be inserted automatically.

      Returns Promise<T>

      The value of the given key or the inserted fallback value if the key does not exist.

    • Creates or updates a key value.

      Type Parameters

      • T

      Parameters

      • key: string

        The key to update.

      • value: T

        The value to set.

      Returns Promise<T>

      The value that was written.