caching-strategies
Skill1 starsChanged 11 months agoMITView on GitHub
Caching patterns and strategies. Auto-activates when implementing caching, Redis, or performance optimization.
Files
Caching Strategies
Cache Patterns
Cache-Aside (Lazy Loading)
async function getUser(id: string): Promise<User> {
// Check cache first
const cached = await redis.get(`user:${id}`);
if (cached) return JSON.parse(cached);
// Cache miss - fetch from DB
const user = await db.users.findById(id);
// Store in cache
await redis.setex(`user:${id}`, 3600, JSON.stringify(user));
return user;
}Write-Through
async function updateUser(id: string, data: Partial<User>) {
// Update DB
const user = await db.users.update(id, data);
// Update cache
await redis.setex(`user:${id}`, 3600, JSON.stringify(user));
return user;
}Write-Behind (Async)
async function updateUser(id: string, data: Partial<User>) {
// Update cache immediately
await redis.setex(`user:${id}`, 3600, JSON.stringify(data));
// Queue DB update (async)
await queue.add('updateUser', { id, data });
return data;
}Cache Invalidation
// Invalidate on update
async function deleteUser(id: string) {
await db.users.delete(id);
await redis.del(`user:${id}`);
}
// Pattern-based invalidation
await redis.del('users:*'); // Delete all user cachesHTTP Caching
// Cache-Control headers
res.set('Cache-Control', 'public, max-age=3600'); // Cache 1 hour
res.set('Cache-Control', 'private, no-cache'); // No caching
res.set('Cache-Control', 'public, max-age=31536000, immutable'); // Static assets
// ETag for conditional requests
const etag = generateETag(data);
res.set('ETag', etag);
if (req.headers['if-none-match'] === etag) {
return res.status(304).end(); // Not Modified
}Cache TTL Guidelines
| Data Type | TTL |
| Static assets | 1 year |
| User sessions | 24 hours |
| API responses | 5-15 minutes |
| Frequently changing | 30-60 seconds |
Redis Data Structures
// String - Simple values
await redis.setex('key', 3600, 'value');
// Hash - Objects
await redis.hset('user:1', { name: 'John', email: 'john@example.com' });
// List - Queues
await redis.lpush('queue', 'item');
// Set - Unique values
await redis.sadd('tags', 'javascript', 'typescript');
// Sorted Set - Rankings
await redis.zadd('leaderboard', 100, 'player1');Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- ThibautBaissac/rails_ai_agents★ 665same name
- cookieMonsterDev/agents-skills★ 7same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- Bappoz/My-Claude-Skills★ 1same name
- michaelsvanbeek/personal-agent-skills★ 1same name
- novatic-cu/nova-skills★ 1same name
- 2867203296/hermes-agent★ 0same name
- dhriyatinandu-bot/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-integrationSkill
- authenticationSkill
- ci-cd-pipelinesSkill
- clean-architectureSkill
- code-patternsSkill
- database-designSkill
- docker-composeSkill
- error-handlingSkill
- frontend-designSkill
- git-workflowSkill
- logging-monitoringSkill
- microservicesSkill
- performance-tuningSkill
- project-setupSkill
- security-best-practicesSkill
- systematic-debuggingSkill
- tddSkill
- testing-strategiesSkill
- websockets-realtimeSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

