UNPKG

@snail-js/api

Version:

Http Request with Decorators Api, build on axios

24 lines (23 loc) 858 B
import MemoryCache from "../cache/memoryCache"; import LocalStorageCache from "../cache/localstorageCache"; import IndexDBCache from "../cache/indexDBCache"; export interface CacheSetData<T = any> { data: T; exp: number; } export type CacheGetData<T = any> = { error: null; data: T; } | { error: Error | Event; data: null; }; export type CacheStorage = MemoryCache | LocalStorageCache | IndexDBCache | CacheStorageAdapter; export declare abstract class CacheStorageAdapter { abstract get<T = any>(key: string): Promise<CacheGetData<T>>; abstract set<T = any>(key: string, value: CacheSetData<T>): Promise<boolean>; abstract delete(key: string): Promise<boolean>; abstract clear(): Promise<boolean>; abstract keys(): Promise<string[]>; } export type AdapterConstructor = new (options?: any) => CacheStorageAdapter;