@web-atoms/core
Version:
26 lines • 685 B
TypeScript
import { App } from "../App";
export type CacheSeconds<T> = number | ((result: T) => number);
export interface ICacheEntry<T> {
/**
* Cache Key, must be unique
*/
key: string;
/**
* Time to Live in seconds, after given ttl
* object will be removed from cache
*/
ttlSeconds?: CacheSeconds<T>;
/**
* Cached value
*/
value?: Promise<any>;
}
export default class CacheService {
private app;
private cache;
constructor(app: App);
remove(key: string): any;
getOrCreate<T>(key: string, task: (cacheEntry?: ICacheEntry<T>) => Promise<T>): Promise<T>;
private clear;
}
//# sourceMappingURL=CacheService.d.ts.map