content-hash-cache-pattern

Cache file processing results using SHA-256 content hashes as keys.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/cescrafli/compyrasion --skill content-hash-cache-pattern-cescrafli
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/cescrafli/compyrasion/tree/main/skills/content-hash-cache-pattern
Command: npx skills add https://github.com/cescrafli/compyrasion --skill content-hash-cache-pattern-cescrafli

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cache expensive file processing results using SHA-256 content hashes as cache keys to ensure path-independence and automatic invalidation when content changes.

Core Features & Use Cases

  • Content-hash based cache keys: use file content to determine cache hits, enabling automatic invalidation on content changes.
  • Service-layer pattern: keep extraction logic pure while caching via a separate layer; minimal intrusion into existing code.
  • File-based cache storage: store entries as hashed.json files to enable O(1) lookups without external indices.

Quick Start

Activate content-hash caching by computing a file's SHA-256 digest, checking the cache, and storing the result if missing.

Frequently Asked Questions about content-hash-cache-pattern

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

FAQPage Schema
How do I cache file processing results by content hash instead of file path?▼

Cache file processing results by computing a file's SHA-256 digest and using it as the cache key. This content-hash approach ensures automatic cache invalidation and path-independence when file content changes.

Why does my file cache return stale data after moving files or renaming directories?▼

File caches keyed by file path return stale data when paths change. Using a content-hash cache pattern based on SHA-256 digests ensures cache hits remain stable regardless of file location or name.

What is the best way to automatically invalidate a cache when file content changes?▼

The best way to automatically invalidate a cache is using a content-hash pattern. By computing SHA-256 hashes as cache keys, any content modification generates a new hash, bypassing stale cache entries automatically.

How to keep file parsing logic pure while adding a caching layer?▼

Keep file parsing logic pure by implementing a separate service-layer pattern for caching. The service layer intercepts requests, checks the JSON-based cache using content hashes, and stores results without intruding on extraction code.

Do I need an external database or index file for file content caching?▼

No external database is needed. The content-hash cache pattern stores entries directly in hashed.json files on disk, enabling O(1) lookups and avoiding the overhead of maintaining separate index files.