Toshihiko
    Preparing search index...

    Interface Cache

    Contract implemented by a Toshihiko cache backend.

    interface Cache {
        deleteData(
            database: string,
            table: string,
            key: CacheKey,
        ): Promise<CacheDeleteResult>;
        deleteKeys(
            database: string,
            table: string,
            keys: readonly CacheKey[],
        ): Promise<CacheDeleteKeysResult>;
        getData<Value extends object>(
            database: string,
            table: string,
            keys: CacheKey | readonly CacheKey[],
        ): Promise<(Value | null)[]>;
        setData<Value extends object>(
            database: string,
            table: string,
            key: CacheKey,
            data: Value,
        ): Promise<CacheSetResult>;
    }

    Implemented by

    Index
    • Reads one or more cached rows.

      The returned array preserves request order; a cache miss occupies its slot as null.

      Type Parameters

      • Value extends object

      Parameters

      • database: string

        Database namespace.

      • table: string

        Model or table namespace.

      • keys: CacheKey | readonly CacheKey[]

        One key or an ordered list of keys.

      Returns Promise<(Value | null)[]>

    • Stores one serialized row.

      Type Parameters

      • Value extends object

      Parameters

      • database: string

        Database namespace.

      • table: string

        Model or table namespace.

      • key: CacheKey

        Row locator or serialized backend key.

      • data: Value

        Plain row data to cache.

      Returns Promise<CacheSetResult>