@hyper-fetch/core
Version:
Cache, Queue and Persist your requests no matter if you are online or offline!
21 lines (18 loc) • 609 B
text/typescript
import type { CacheAsyncStorageType, CacheOptionsType } from "cache";
import { Cache } from "cache";
import type { ClientInstance } from "client";
export const createCache = (client: ClientInstance, options?: CacheOptionsType) => {
return new Cache(options).initialize(client);
};
export const createLazyCacheAdapter = (storage: Map<any, any>): CacheAsyncStorageType => {
return {
get: async (key) => storage.get(key),
set: async (key, value) => {
storage.set(key, value);
},
keys: async () => storage.keys(),
delete: async (key) => {
storage.delete(key);
},
};
};