content-hash-cache-pattern

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

3|1|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN --skill content-hash-cache-pattern-oabdelmaksoud
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN/tree/main/ecc-resources/docs/zh-CN/skills/content-hash-cache-pattern
Command: npx skills add https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN --skill content-hash-cache-pattern-oabdelmaksoud

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill caches the results of expensive file processing tasks (like PDF parsing or image analysis) using content hashes, ensuring that results are valid even if files are moved or renamed, and automatically invalidating the cache when content changes.

Core Features & Use Cases

  • Content-Based Caching: Uses SHA-256 hashes of file content as cache keys, making the cache path-independent.
  • Automatic Cache Invalidation: Cache entries are automatically invalidated when the file content changes.
  • Separated Service Layer: Keeps expensive processing functions pure by handling caching logic in a separate wrapper.
  • Use Case: When processing a batch of documents, this pattern ensures that if the same document (even if moved to a different directory) is encountered again, its previously computed analysis is reused, saving significant processing time.

Quick Start

Use the content-hash-cache-pattern skill to extract text from the file located at '/path/to/document.pdf' with caching enabled.

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 expensive PDF parsing results to avoid reprocessing identical files?

Cache document analysis results by using a service layer wrapper that generates SHA-256 hashes as cache keys for file content. This automatically reuses previously computed outputs for identical files, saving significant processing time in document batch pipelines.

How does content hashing handle cache invalidation when files are moved or modified?

Content hashing uses SHA-256 hashes of file content as cache keys instead of file paths. This makes the cache path-independent so results remain valid if files are renamed or moved, and automatically invalidates entries when file content changes.

What is the best way to separate caching logic from pure file extraction functions in Python?

Use a service layer wrapper to handle caching logic around pure extraction functions. This pattern manages cache entry storage via Python's hashlib and dataclasses, keeping expensive document processing functions pure and separated from I/O operations.

Does this content-hash caching pattern require specific Python libraries for cache entry management?

Yes, this content-hash caching pattern requires Python's standard hashlib to compute SHA-256 hashes and dataclasses for cache entry management. It also uses standard file I/O operations to store and retrieve cached document processing results.

When should I use a content-based cache instead of a path-based cache for document analysis?

Use a content-based cache when processing document batches where identical files might appear across different paths. SHA-256 hashing ensures cache validity across directories and automatic invalidation upon content modification, unlike path-based caches that break when files move.