Type Alias ICache<TType>

ICache<TType>: ICacheListenable & {
    add(key: string, value: TType, ttl?: null | TimeSpan): LazyPromise<boolean>;
    addMany<TKeys>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
    clear(): LazyPromise<void>;
    decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
    exists(key: string): LazyPromise<boolean>;
    existsMany<TKeys>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
    get(key: string): LazyPromise<null | TType>;
    getAndRemove(key: string): LazyPromise<null | TType>;
    getGroup(): string;
    getMany<TKeys>(keys: TKeys[]): LazyPromise<Record<TKeys, null | TType>>;
    getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
    getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>, ttl?: null | TimeSpan): LazyPromise<TType>;
    getOrFail(key: string): LazyPromise<TType>;
    getOrMany<TKeys>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
    increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
    missing(key: string): LazyPromise<boolean>;
    missingMany<TKeys>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
    put(key: string, value: TType, ttl?: null | TimeSpan): LazyPromise<boolean>;
    putMany<TKeys>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
    remove(key: string): LazyPromise<boolean>;
    removeMany<TKeys>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
    update(key: string, value: TType): LazyPromise<boolean>;
    updateMany<TKeys>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
}

The ICache contract defines a way for storing data as key-value pairs independent of data storage. It commes with more convient methods compared to ICacheAdapter.

Type Parameters

  • TType = unknown

Type declaration