@jbagatta/johnny-cache
Version:
A robust distributed dictionary for coordinating and caching expensive operations in a distributed environment
20 lines (19 loc) • 967 B
TypeScript
import { CacheOptions, DistributedDictionary, KeyStatus } from "./types";
import { L1CacheManager } from "./l1-cache/l1-cache-manager";
import { IDistributedLock } from "@jbagatta/johnny-locke";
export declare class JohnnyCache<K, V> implements DistributedDictionary<K, V> {
private readonly lock;
private readonly cacheOptions;
private readonly l1Cache?;
constructor(lock: IDistributedLock, cacheOptions: CacheOptions, l1Cache?: L1CacheManager | undefined);
private keyString;
asyncBuildOrRetrieve(key: K, buildFunc: () => Promise<V>, callback: (value?: V, err?: any) => Promise<void>, timeoutMs: number): void;
buildOrRetrieve(key: K, buildFunc: () => Promise<V>, timeoutMs: number): Promise<V>;
get(key: K, timeoutMs: number): Promise<V>;
status(key: K): Promise<KeyStatus>;
delete(key: K): Promise<void>;
close(): Promise<void>;
private insertIntoL1Cache;
private tryGetFromL1Cache;
private updateExpiry;
}