caching-strategies
Skill1 starsChanged 4 months agoMITView on GitHub
Estratégias de cache production-grade: padrões (cache-aside, read/write-through, write-behind), invalidação, TTL, camadas (browser/CDN/app/DB), cache stampede e chaves. Use quando o usuário mencionar: "cache", "caching", "invalidação de cache", "Redis", "CDN", "TTL", "cache-aside", "memoization", "cache stampede", "dados velhos", "acelerar leitura". Liga com [[performance]] e [[system-design]].
11 other projects use a version of this.
Adopted by
Most recently taken up by
- sf-scalar/skiLL.Mdtheir own version, first seen Nov 8, 2026
- reddygopalkrishna/developer-agent-skillstheir own version, first seen Nov 8, 2026
- cookieMonsterDev/agents-skillstheir own version, first seen Nov 1, 2026
- ThibautBaissac/rails_ai_agentstheir own version, first seen Oct 8, 2026
- novatic-cu/nova-skillstheir own version, first seen Sep 20, 2026
- 2867203296/hermes-agenttheir own version, first seen Aug 19, 2026
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- ThibautBaissac/rails_ai_agents★ 665same name
- reddygopalkrishna/developer-agent-skills★ 8same name
- cookieMonsterDev/agents-skills★ 7same name
- sf-scalar/skiLL.Md★ 6same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- harrissohail6/claude-code-config★ 1same name
- michaelsvanbeek/personal-agent-skills★ 1same name
- novatic-cu/nova-skills★ 1same name
- 2867203296/hermes-agent★ 0same name
1 more not listed
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 repository70 other files it gives its agents.
- agent-creationSkill
- handoffSkill
- task-distributorSkill
- task-plannerSkill
- accessibilitySkill
- airbnb-designSkill
- airtable-designSkill
- atlassian-designSkill
- carbon-designSkill
- cloudscape-designSkill
- coinbase-designSkill
- discord-designSkill
- duolingo-designSkill
- figma-designSkill
- fluent-designSkill
- linear-designSkill
- material-designSkill
- meta-designSkill
- netflix-designSkill
- notion-designSkill
- nubank-designSkill
- one-ui-designSkill
- pinterest-designSkill
- polaris-designSkill
- premium-web-designSkill
- primer-designSkill
- reddit-designSkill
- revolut-designSkill
- robinhood-designSkill
- salesforce-lightning-designSkill
- slack-designSkill
- spectrum-designSkill
- spotify-designSkill
- stripe-designSkill
- tiktok-designSkill
- twitch-designSkill
- uber-base-designSkill
- vercel-geist-designSkill
- visionos-designSkill
- whatsapp-designSkill
- economicsSkill
- legal-basicsSkill
- negotiationSkill
- politicalSkill
- api-designSkill
- architectureSkill
- ci-cdSkill
- database-designSkill
- event-drivenSkill
- observabilitySkill
- payment-systemsSkill
- performanceSkill
- qaSkill
- refactoringSkill
- securitySkill
- system-designSkill
- testingSkill
- clone-websiteSkill
- graphifySkill
- remotionSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 38
Default pragmático: cache-aside + TTL.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Caching Strategies
Você atua como engenheiro de performance de dados. Cache troca frescor por velocidade e custo. A parte fácil é guardar; a difícil — e onde moram os bugs — é invalidar. Cacheie com propósito, não por reflexo.
"There are only two hard things in Computer Science: cache invalidation and naming things." — Phil Karlton
Quando cachear (e quando não)
Cacheie quando: leitura ≫ escrita, o dado é caro de computar/buscar, e um pouco de staleness é tolerável. Não cacheie quando: o dado muda a cada leitura, precisa ser sempre exato (saldo — ver [[payment-systems]]), ou a taxa de acerto seria baixa (cache frio custa sem ganhar).
Camadas (mais perto do usuário = mais rápido/barato)
Browser (HTTP cache) → CDN (edge) → Cache de app (Redis) → Banco (buffer pool)Cacheie na camada mais externa que a corretude permite. Um asset estático vai à CDN; uma query cara vai ao Redis; uma resposta por-usuário não vai em camada compartilhada sem chave por usuário.
Padrões de cache
| Padrão | Como | Bom para | Cuidado |
| Cache-aside (lazy) | App lê cache; miss → busca no DB e popula | O mais comum; leitura | Primeiro acesso é miss; risco de stale |
| Read-through | O cache busca no DB por você (via lib) | Simplifica o app | Acopla ao provedor de cache |
| Write-through | Escreve no cache e no DB juntos | Cache sempre fresco na escrita | Latência de escrita maior |
| Write-behind | Escreve no cache; DB async depois | Escrita rápida, absorve picos | Risco de perda se cair antes de persistir |
Default pragmático: cache-aside + TTL.
async function getUser(id) {
const key = `user:${id}`;
let u = await redis.get(key);
if (u) return JSON.parse(u); // hit
u = await db.users.find(id); // miss → busca
await redis.set(key, JSON.stringify(u), 'EX', 300); // popula com TTL 5min
return u;
}Invalidação (o problema difícil)
Três abordagens (combine):
- TTL / expiração — simples e robusto: aceite dado velho por até N segundos. Escolha o TTL pela tolerância do negócio.
- Invalidação na escrita — ao atualizar o dado, apague/atualize a chave (
redis.del(key)). Preciso, mas exige achar todas as chaves afetadas. - Versão/tag na chave — inclua versão no key (
user:123:v7); bump da versão invalida em massa sem apagar.
Regra: prefira apagar (del) a atualizar a chave na escrita — mais simples e menos sujeito a corrida.
Cache stampede (thundering herd)
Quando uma chave popular expira, mil requests simultâneos furam para o DB de uma vez. Mitigações: lock/single-flight (só um recomputa, o resto espera), TTL jitter (espalhar expiração), early recompute (renovar antes de expirar), stale-while-revalidate (servir o velho enquanto atualiza em background).
Boas práticas de chave
- Namespace claro:
entidade:id:campo(order:42:items). - Inclua o que muda o resultado (idioma, versão, usuário) na chave — senão serve resposta errada.
- Nunca cacheie dado por-usuário sob chave global.
Recursos externos
| Recurso | O que pegar |
| Redis — Caching patterns | Cache-aside, TTL, estruturas, locks. |
| AWS — Caching best practices | Camadas, TTL, invalidação. |
| MDN — HTTP Caching | Cache-Control, ETag, stale-while-revalidate. |
| Cloudflare — What is a CDN | Cache de borda. |
| Facebook — Scaling Memcache | Stampede/leases em escala real. |
| [[performance]] · [[system-design]] | Onde o cache entra na performance/arquitetura. |
Do / Don't
| Do | Don't |
| Cache-aside + TTL como base | Cachear tudo por reflexo |
| Apagar chave na escrita | Tentar atualizar e correr risco de corrida |
| Chave inclui tudo que muda o resultado | Chave global para dado por-usuário |
| Mitigar stampede (lock/jitter/SWR) | Deixar chave popular expirar sem proteção |
| Cachear na camada mais externa segura | Cachear dado que precisa ser exato |
Checklist
- Confirmado leitura ≫ escrita e staleness tolerável
- Padrão escolhido (default: cache-aside + TTL)
- TTL definido pela tolerância do negócio
- Invalidação na escrita (preferir del) + versão/tag quando útil
- Proteção contra stampede em chaves quentes
- Chaves com namespace e todas as dimensões que afetam o resultado
- Nada exato/por-usuário cacheado indevidamente
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.

