UNPKG

@zenweb/cache

Version:
12 lines (11 loc) 516 B
import { Context, Middleware } from "@zenweb/core"; import { LockGetOption } from "./types.js"; type CachedMiddlewareOption = Omit<LockGetOption, 'parse' | 'decompress'>; /** * 缓存中间件 * - 缓存 ctx.success() 结果 * - fail() 时不缓存 * @param key 不指定 `key` 则默认使用 `ctx.path`,`key: null` 不适用使用缓存 */ export declare function cached(key?: string | null | ((ctx: Context) => string | null | Promise<string | null>), opt?: CachedMiddlewareOption): Middleware; export {};