Content Preview
--- name: content-hash-cache-pattern description: 使用SHA-256内容哈希缓存昂贵的文件处理结果——路径无关、自动失效、服务层分离。 origin: ECC --- # 内容哈希文件缓存模式 使用 SHA-256 内容哈希作为缓存键,缓存昂贵的文件处理结果(PDF 解析、文本提取、图像分析)。与基于路径的缓存不同,此方法在文件移动/重命名后仍然有效,并在内容更改时自动失效。 ## 何时激活 * 构建文件处理管道时(PDF、图像、文本提取) * 处理成本高且同一文件被重复处理时 * 需要一个 `--cache/--no-cache` CLI 选项时 * 希望在不修改现有纯函数的情况下为其添加缓存时 ## 核心模式 ### 1. 基于内容哈希的缓存键 使用文件内容(而非路径)作为缓存键: ```python import hashlib from pathlib import Path _HASH_CHUNK_SIZE = 65536 # 64KB chunks for large files def compute
How to Use
Recommended: Install to project (local)
mkdir -p .claude/skills
curl -o .claude/skills/content-hash-cache-pattern.md \
https://raw.githubusercontent.com/affaan-m/everything-claude-code/main/docs/zh-CN/skills/content-hash-cache-pattern/SKILL.mdSkill is scoped to this project only. Add .claude/skills/ to your .gitignoreif you don't want to commit it.
Alternative: Clone full repo
git clone https://github.com/affaan-m/everything-claude-codeThen reference at docs/zh-CN/skills/content-hash-cache-pattern/SKILL.md
Related Skills
content-engine
Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.
content-enginecontentengine
by affaan-m · everything-claude-code
apify-content-analytics
Track engagement metrics, measure campaign ROI, and analyze content performance across Instagram, Facebook, YouTube, and TikTok.
data-aiapifycontentanalytics
by sickn33 (Antigravity) · antigravity-awesome-skills
content-creator
Professional-grade brand voice analysis, SEO optimization, and platform-specific content frameworks.
businesscontentcreator
by sickn33 (Antigravity) · antigravity-awesome-skills
content-marketer
Elite content marketing strategist specializing in AI-powered content creation, omnichannel distribution, SEO optimization, and data-driven performance marketing.
data-aicontentmarketer
by sickn33 (Antigravity) · antigravity-awesome-skills