AgentStack
SKILL verified MIT Self-run

Caching Strategies

skill-cosmicstack-labs-mercury-agent-skills-caching-strategies · by cosmicstack-labs

CDN, Redis, in-memory cache, cache invalidation, and distributed caching patterns

No reviews yet
0 installs
17 views
0.0% view→install

Install

$ agentstack add skill-cosmicstack-labs-mercury-agent-skills-caching-strategies

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Caching Strategies? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Caching Strategies

Cache effectively to improve performance and reduce load.

Cache Layers

| Layer | Latency | Storage | Examples | |-------|---------|---------|----------| | Browser | Local | Small | localStorage, HTTP cache | | CDN | Regional | Large | CloudFront, CloudFlare, Fastly | | Application | In-process | Small | L1 cache (heap) | | Distributed | Network | Large | Redis, Memcached | | Database | Same host | Very large | Buffer pool, query cache |

Caching Patterns

Cache-Aside (Lazy Loading)

1. Check cache → miss
2. Query database
3. Store in cache
4. Return

Best for: Read-heavy, general purpose.

Write-Through

1. Write to cache
2. Cache writes to DB (sync)
3. Return

Best for: Consistency critical, write-heavy.

Write-Behind

1. Write to cache
2. Return immediately
3. Cache writes to DB (async)

Best for: High throughput writes, eventual consistency OK.

Refresh-Ahead

  • Cache proactively refreshes before expiry
  • Reduces latency spikes on cache miss
  • Requires predictive logic or scheduled refresh

Cache Invalidation

Two hard things: naming, cache invalidation, off-by-one errors.

| Strategy | How | Risk | |----------|-----|------| | TTL | Expire after X seconds | Stale data during TTL | | Event-based | Invalidate on data change | Missed events | | Version keys | user_42_v3 | Unused old keys accumulate | | Write-through | Update cache on write | Write amplification |

Redis Patterns

  • Use EXPIRE on every SET
  • Use SCAN not KEYS in production
  • Distributing: Redis Cluster for sharding
  • Backup: RDB (snapshot) + AOF (append-only log)
  • Monitor: hit rate, memory, evictions, latency

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.