SKILL

content-hash-cache-pattern

Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation. Use when repeated file processing is slow and results should be cached and invalidated by content rather than path.

Target: Target not categorized. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original English text

Topics in the source

  • Content-Hash File Cache Pattern
  • When to Activate
  • Core Pattern
  • 1. Content-Hash Based Cache Key
  • 2. Frozen Dataclass for Cache Entry
  • 3. File-Based Cache Storage
  • 4. Service Layer Wrapper (SRP)
  • Key Design Decisions

Cache expensive file processing results (PDF parsing, text extraction, image analysis) using SHA-256 content hashes as cache keys. Unlike path-based caching, this approach survives file moves/renames and auto-invalidates when content changes. Building file processing pipelines (PDF, images, text extraction) Processing cost is high and same files are processed repeatedly Need a --cache/--no-cache CLI option Want to add caching to existing pure functions without modifying them Use file content (not path) as the cache key: Why content hash? File rename/move = cache hit. Content change = automatic invalidation. No index file needed. Each cache entry is stored as {hash}.json — O(1) lookup by hash, no index file required. Keep the processing function pure. Add caching as a separate service layer. | Decision | Rationale | |----------|-----------| | SHA-256 content hash | Path-independent, auto-invalidates on content change | | {hash}.json file naming | O(1) lookup, no index file needed | | Service layer wrapper | SRP: extraction stays pure, cache is a separate concern | | Manual JSON serialization | Full control over frozen dataclass serialization | | Corruption returns None | Graceful de

This is an excerpt. Refer to the complete source and its current requirements.

Source repository
affaan-m/ECC
Source file
pi/core/skills/content-hash-cache-pattern/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.895Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.