@httpc/kit
Version:
httpc toolbox for building function-based API with minimal code and end-to-end type safety
22 lines (21 loc) • 1.18 kB
TypeScript
import type { ILogger } from "../logging";
import { CacheKey, CachingGetOptions, ICache, ICachingService } from "./types";
type CacheFactory = (service: CachingService) => ICache;
export type CachingServiceOptions = {
log?: boolean;
caches?: Record<CacheKey, CacheFactory>;
};
declare const CachingService_base: {
new (logger: ILogger, ...args: any[]): import("../services")._BaseService<"not_found" | "invalid_param" | "unauthorized" | "forbidden" | "not_allowed" | "invalid_state" | "misconfiguration" | "not_supported" | "processing_error">;
};
export declare class CachingService extends CachingService_base implements ICachingService {
protected readonly options?: CachingServiceOptions | undefined;
protected readonly factories: Map<string, CacheFactory>;
protected readonly caches: Map<string, ICache<any>>;
constructor(logger: ILogger, options?: CachingServiceOptions | undefined);
getCache<V>(key: CacheKey, options?: CachingGetOptions): ICache<V>;
removeCache(key: CacheKey): void;
register(key: string, factory: CacheFactory): void;
protected _instantiateCache(key: string): ICache<any>;
}
export {};