UNPKG

ts-ioc-container

Version:
23 lines (22 loc) 787 B
export interface Cache<K, V> { getKey(...args: unknown[]): K; hasValue(key: K): boolean; getValue(key: K): V; setValue(key: K, value: V): void; } export declare class MultiCache<K, V> implements Cache<K, V> { readonly getKey: (...args: unknown[]) => K; private instances; constructor(getKey?: (...args: unknown[]) => K); hasValue(token: K): boolean; getValue(token: K): V; setValue(token: K, value: V): void; } export declare const multiCache: <K, V>(getKey: (...args: unknown[]) => K) => MultiCache<K, V>; export declare class SingleCache<V> implements Cache<string, V> { private instance?; getKey(...args: unknown[]): string; getValue(key: string): V; hasValue(key: string): boolean; setValue(key: string, value: V): void; }