UNPKG

@amirmarmul/waba-common

Version:

![GitHub release](https://img.shields.io/github/v/release/amirmarmul/waba-common?style=flat-square)

48 lines (47 loc) 1.64 kB
import { Repo } from '../../../core/infrastructure/cache/Repo'; type CacheDriver = 'null' | 'array' | 'file' | 'redis'; type StoreConfig = { driver: CacheDriver; [key: string]: any; }; export type CacheConfig = { store: string; stores: { [key: string]: StoreConfig; }; prefix: string; }; export declare class Cache { protected stores: { [key: string]: Repo; }; protected readonly config: CacheConfig; constructor(config: CacheConfig); driver(driver?: CacheDriver): Repo; protected store(name?: string): Repo; protected resolve(name: string): any; protected getConfig(name: string): { driver: string; }; protected getPrefix(): string; protected getDefaultDriver(): string; protected nullDriver(config: StoreConfig): Repo; protected arrayDriver(config: StoreConfig): Repo; protected fileDriver(config: StoreConfig): Repo; protected redisDriver(config: StoreConfig): Repo; /** * CacheContract */ has(key: string): Promise<boolean>; missing(key: string): Promise<boolean>; get<T>(key: string, _default?: any): Promise<T | null>; pull<T>(key: string, _default?: any): Promise<T | null>; put(key: string, value: any, ttl?: number): Promise<boolean>; add(key: string, value: any, ttl?: number): Promise<boolean>; forever(key: string, value: any): Promise<boolean>; remember<T>(key: string, callback: Function, ttl?: number): Promise<T>; rememberForever<T>(key: string, callback: Function): Promise<T>; forget(key: string): Promise<boolean>; flush(): Promise<boolean>; } export {};