Toshihiko
    正在准备搜索索引...

    接口 Cache

    Toshihiko Cache 后端实现的契约。

    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>;
    }

    实现于

    索引
    • 删除一行缓存数据。

      参数

      • database: string

        数据库命名空间。

      • table: string

        Model 或表的命名空间。

      • key: CacheKey

        数据行定位条件或序列化后的后端 key。

      返回 Promise<CacheDeleteResult>

    • 读取一行或多行缓存数据。

      返回数组保持请求顺序;缓存未命中会在对应位置使用 null。

      类型参数

      • Value extends object

      参数

      • database: string

        数据库命名空间。

      • table: string

        Model 或表的命名空间。

      • keys: CacheKey | readonly CacheKey[]

        一个 key 或按顺序排列的 key 列表。

      返回 Promise<(Value | null)[]>

    • 存储一行序列化数据。

      类型参数

      • Value extends object

      参数

      • database: string

        数据库命名空间。

      • table: string

        Model 或表的命名空间。

      • key: CacheKey

        数据行定位条件或序列化后的后端 key。

      • data: Value

        要缓存的普通数据行。

      返回 Promise<CacheSetResult>