Skip to content
Back to skills

Cache

ASecurity

Add caching (memoize/LRU/HTTP) where it pays off, with correct keys and invalidation

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
ai-agentsgoperformance

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill cache --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cache?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cache
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-cache/badge)](https://www.skillsdirectory.com/skills/black141312-cache)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cache
description: Add caching (memoize/LRU/HTTP) where it pays off, with correct keys and invalidation
category: performance
---

# Cache

Reach for this when the same expensive computation or fetch repeats with identical inputs and recomputing is the bottleneck.

1. Confirm the work is cacheable: deterministic for a given key, read-heavy, and expensive enough that caching beats the lookup overhead.
2. Define the cache key precisely — include every input that changes the result; exclude volatile or irrelevant fields.
3. Pick the layer: memoize a pure function, an in-process LRU with a size cap, a shared store (Redis), or HTTP `Cache-Control`/`ETag` for responses.
4. Set bounds: max entries or memory cap plus a TTL, so the cache can't grow unbounded or serve stale data forever.
5. Define invalidation up front — TTL expiry, write-through on update, or explicit bust on the events that change the source.
6. Measure hit rate and latency before/after; if the hit rate is low or correctness gets fragile, remove it.

## Rules
- An unbounded cache is a memory leak — always cap size and/or TTL.
- A wrong key is worse than no cache: too broad serves stale results, too narrow never hits.
- Don't cache cheap, fast, or rarely-repeated work — the bookkeeping costs more than it saves.
- Cache invalidation is the hard part; prefer TTL or write-through over hand-rolled bust logic.
- Never cache per-user or sensitive data in a shared/global cache without scoping the key to the user.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…