Content Hash Cache Pattern

当为高成本、可重复的文件处理(PDF 解析、OCR、文本/图像抽取)加缓存、需要 --cache/--no-cache 开关、且不想改动现有纯函数时使用;用文件内容的 SHA-256 作缓存键、按 {hash}.json 落盘、以独立服务层包裹纯处理函数,产出路径无关、内容变即自动失效、损坏即视为未命中的缓存方案;不适用于必须实时最新的数据、超大缓存条目(改用流式)、或结果还依赖内容之外参数(如抽取配置)的场景;触发词:内容哈希、SHA-256、文件缓存、缓存失效、纯函数

findscripter 63cfb8f 6.6 KB Updated

File contents

findscripter/everything-skills/tree/main/02-engineering/content-hash-cache-pattern commit 63cfb8f7bf

Frequently asked questions

npx skillmds@latest add findscripter/content-hash-cache-pattern