axios-etag-cache
Version:
Axios etag interceptor to enable If-None-Match request with ETAG support
31 lines (30 loc) • 1.01 kB
TypeScript
export interface ConstructableCache<T> {
new (...args: any): T;
}
export declare abstract class BaseCache {
abstract get(key: string): Promise<CacheValue | undefined>;
abstract set(key: string, value: CacheValue): any;
abstract flushAll(): any;
}
export declare class DefaultCache extends BaseCache {
private cache;
get(key: string): Promise<CacheValue | undefined>;
set(key: string, value: CacheValue): void;
flushAll(): void;
}
export declare class LocalStorageCache extends BaseCache {
flushAll(): void;
get(key: string): Promise<CacheValue | undefined>;
set(key: string, value: CacheValue): void;
}
export interface CacheValue {
etag: string;
value: any;
createdAt: number;
lastHitAt: number;
}
export declare const getCacheInstance: (cacheClass: ConstructableCache<BaseCache>) => {
get(uuid: string): Promise<CacheValue | undefined>;
set(uuid: string, etag: string, value: any): any;
reset(): void;
};