with-simple-caching
Version:
A wrapper that makes it simple to add caching to any function
19 lines (18 loc) • 829 B
TypeScript
import { SimpleCache } from '../../domain/SimpleCache';
import { WithExtendableCachingTrigger } from '../wrappers/withExtendableCachingAsync';
import { WithSimpleCachingCacheOption } from './getCacheFromCacheOption';
/**
* a function which is capable of grabbing the cache from arguments to the `invalidate` or `update` commands, supporting both the case when invoked with `forInput` and when invoked with `forKey`
*/
export declare const getCacheFromCacheOptionOrFromForKeyArgs: <L extends (...args: any) => any, C extends SimpleCache<any>>({ args, options, trigger, }: {
args: {
forKey: string;
cache?: C | undefined;
} | {
forInput: Parameters<L>;
};
options: {
cache: WithSimpleCachingCacheOption<Parameters<L>, C>;
};
trigger: WithExtendableCachingTrigger;
}) => C;