@praha/envelop-request-cache
Version:
This plugin caches arbitrary values within the request scope to optimize execution flow
12 lines (11 loc) • 598 B
TypeScript
import { AsyncLocalStorage } from 'node:async_hooks';
import type { Plugin } from '@envelop/core';
export type CreateRequestCachePluginOptions = {
storage?: AsyncLocalStorage<Record<string, unknown>>;
};
export declare const createRequestCachePlugin: (options?: CreateRequestCachePluginOptions) => {
cache: <T extends (...args: any[]) => any>(callback: T, keys?: string[]) => T;
evict: () => void;
useRequestCache: () => Plugin;
};
export declare const cache: <T extends (...args: any[]) => any>(callback: T, keys?: string[]) => T, evict: () => void, useRequestCache: () => Plugin;