content-hash-cache-pattern

Cache file processing results using SHA-256 content hashes.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/riftzen-bit/gemini-setup --skill content-hash-cache-pattern-riftzen-bit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/riftzen-bit/gemini-setup/tree/main/skills/content-hash-cache-pattern
Command: npx skills add https://github.com/riftzen-bit/gemini-setup --skill content-hash-cache-pattern-riftzen-bit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cache expensive file processing results using SHA-256 content hashes as cache keys. Unlike path-based caching, this approach survives file moves/renames and auto-invalidates when content changes.

Core Features & Use Cases

  • Content-hash based cache key: use file content for cache lookups, ensuring cache hits across moves/renames.
  • Service-layer caching: separate cache logic from pure processing to preserve determinism.
  • File-based cache storage: store cache entries as hash.json for quick retrieval.

Quick Start

Run the processor with the content-hash cache enabled to automatically cache results when processing files.

Frequently Asked Questions about content-hash-cache-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does content-hash caching work for file processing pipelines?

Content-hash caching uses SHA-256 hashes of file content as cache keys, ensuring cache lookups survive file moves or renames and automatically invalidate when content changes. Cache entries are stored as hash.json files for quick retrieval.

What's the best way to cache PDF and image processing results safely?

The best approach is using a service-layer caching wrapper with SHA-256 content hashing, which separates cache logic from pure file processing to preserve determinism while safely reusing expensive PDF or image extraction results across runs.

Why does path-based caching fail when files are moved or renamed?

Path-based caching fails because file moves or renames change the path used as the lookup key, causing cache misses. Using a SHA-256 content hash as the cache key ensures identical content hits the cache regardless of its file path.

How do I keep file processing deterministic when adding a cache layer?

You keep file processing deterministic by implementing a service-layer caching wrapper that separates cache logic from the pure processing function, ensuring the core extraction logic remains pure and unaffected by cache state.

When should I not use content-hash caching for file processing?

You should avoid content-hash caching when file processing is inexpensive, as computing SHA-256 hashes adds overhead. It is designed for expensive file processing pipelines where identical content appears across multiple runs.