content-hash-cache-pattern

Cache expensive file processing results using SHA-256 content hashes.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill caches the results of expensive file processing tasks, ensuring that the same computation isn't repeated for identical file content, even if the file's location changes.

Core Features & Use Cases

  • Content-Based Caching: Uses SHA-256 hashes of file content as cache keys, making the cache independent of file paths.
  • Automatic Invalidation: Cache entries are automatically invalidated when file content is modified.
  • Service Layer Separation: Encapsulates caching logic outside of pure processing functions, adhering to the Single Responsibility Principle.
  • Use Case: When processing numerous PDF documents for text extraction, this Skill prevents re-parsing already processed files, significantly speeding up batch operations and saving computational resources.

Quick Start

Use the content-hash-cache-pattern skill to extract text from the file 'report.pdf' using a cache directory named '.my_cache'.

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 based on content instead of file paths?

Cache file processing results based on content by using SHA-256 hashes as cache keys. This method creates a content-addressable cache that remains valid even if files are renamed or moved across different paths.

Why does my file cache become invalid after renaming or moving files?

File caches become invalid after renaming because they typically rely on file paths. Using SHA-256 content hashing for cache keys ensures identical file contents are recognized regardless of their path or filename.

How do I automatically invalidate a cache when file content changes?

Automatically invalidate a cache when file content changes by computing a SHA-256 hash of the content as the cache key. Any modification alters the hash, ensuring stale results are never retrieved.

What is the best way to avoid redundant computations when batch processing PDF files?

Avoid redundant computations when batch processing PDF files by implementing a content-addressable cache. This prevents re-parsing identical documents by checking their SHA-256 hashes first.

Can I separate caching logic from pure file processing functions?

You can separate caching logic from pure file processing functions by using a service layer separation approach. This adheres to the Single Responsibility Principle while managing SHA-256 cache operations independently.

When should I use content hashing for memoization instead of path-based caching?

Use content hashing for memoization instead of path-based caching when files might be renamed, moved, or duplicated across directories. SHA-256 hashing ensures path-independent, auto-invalidating cache entries.