content-hash-cache-pattern
Installation
SKILL.md
Content-Hash File Cache Pattern
コンテンツハッシュキャッシュパターン
Extracted / 抽出日: 2026-02-10 Context / コンテキスト: ファイル処理結果をSHA-256ハッシュでキャッシュし、サービス層でラップするパターン
Problem / 課題
ファイル処理(PDF解析、テキスト抽出等)は時間がかかるが、同じファイルの再処理は無駄:
# WRONG: 毎回フルパイプライン実行
def process_file(path: Path) -> Result:
return expensive_extraction(path) # Always re-runs
# WRONG: パスベースキャッシュ(ファイル移動で無効化)
cache = {"/path/to/file.pdf": result} # Path changes → cache miss