simple-on-disk-cache
Version:
A simple on-disk cache, supporting local and remote filesystem targets, with time based expiration policies.
37 lines (36 loc) • 1.33 kB
TypeScript
import { type Serializable } from 'serde-fns';
/**
* .what = casts details about the execution of a procedure into a safe on disk cache key
* .why =
* - eliminates special characters, which are incompatible with on-disk file names
* - ensures to namespace to a procedure name, to avoid cross procedures cache-key collisions
* - reminds to use a procedure.version, to enable invalidation of prior versions of procedures
*/
export declare const castToSafeOnDiskCacheKey: <TInput extends Serializable>(input: {
/**
* .what = info about the procedure you'd like to cache for
*/
procedure: {
/**
* .what = the name of the procedure to cache for
* .why =
* - ensures that each procedure gets its own namespace in the cache
*/
name: string;
/**
* .what = the version of the procedure to cache for
* .why =
* - ensures that if you upgrade the logic within your procedure, you can invalidate all of the prior cached results
*/
version: string | null;
};
/**
* .what = info about the execution of the procedure that you'd like to cache for
*/
execution: {
/**
* the input that the procedure was executed with
*/
input: TInput;
};
}) => string;