Type Alias IDatabaseCacheAdapter<TType>

IDatabaseCacheAdapter: {
    find(key: string): PromiseLike<null | ICacheData<TType>>;
    incrementUnexpired(data: ICacheUpdate<number>): PromiseLike<number>;
    insert(data: ICacheInsert<TType>): PromiseLike<void>;
    removeAll(): PromiseLike<void>;
    removeByKeyPrefix(prefix: string): PromiseLike<void>;
    removeExpiredMany(keys: string[]): PromiseLike<number>;
    removeUnexpiredMany(keys: string[]): PromiseLike<number>;
    updateExpired(data: ICacheInsert<TType>): PromiseLike<number>;
    updateUnexpired(data: ICacheUpdate<TType>): PromiseLike<number>;
    upsert(data: ICacheInsert<TType>): PromiseLike<null | ICacheDataExpiration>;
}

The IDatabaseCacheAdapter contract defines a way for as key-value pairs independent of data storage. This contract simplifies the implementation of cache adapters with CRUD-based databases, such as SQL databases and ORMs like TypeOrm and MikroOrm.

IMPORT_PATH: "@daiso-tech/core/cache/contracts"

Type Parameters

  • TType = unknown

Type declaration