caching_skill

This skill helps you implement caching with robust invalidation strategies to boost performance while ensuring data freshness.
  • TypeScript

6

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill yanko-belov/code-craft --skill caching

  • SKILL.md6.3 KB

Overview

This skill guides implementing caching responsibly in TypeScript services. It emphasizes performance gains while enforcing a mandatory invalidation strategy to avoid stale data and memory issues. Use it to add caches that are predictable, bounded, and maintainable.

How this skill works

The skill inspects caching patterns and enforces the rule: never introduce a cache without a defined invalidation strategy. It shows concrete patterns (TTL, write-through, event-based, cache-aside) and code examples for in-memory and Redis caches. It also highlights anti-patterns, detection heuristics, and concrete responses to common stakeholder pushback.

When to use it

  • When the same data is fetched repeatedly
  • When database queries or computations are expensive
  • When external API rate limits or latency matter
  • When asked to "just add caching" without a plan
  • For read-heavy endpoints tolerant of controlled staleness

Best practices

  • Always define an invalidation strategy before adding a cache (TTL, write-through, or event-based).
  • Use TTL plus explicit invalidation on writes; combine strategies for distributed systems.
  • Set memory/size limits and eviction policies to avoid leaks in long-running processes.
  • Prefer event-based invalidation or pub/sub in distributed deployments.
  • Avoid caching rapidly changing or security-sensitive data (sessions, payment status).

Example use cases

  • Cache product catalog responses with short TTL and write-through on updates.
  • Cache user profiles with cache-aside plus invalidate on profile updates via event bus.
  • Cache expensive computed aggregates with TTL and periodic recompute jobs.
  • Use Redis for cross-instance caches and keys with setex TTL and pattern invalidation.
  • Wrap database reads in a cache-aside layer for read-heavy APIs to reduce DB load.

FAQ

Rarely ≠ never. Add at minimum a TTL and invalidate on writes to avoid hard-to-debug stale data.

Is TTL alone sufficient?

TTL helps but can still allow unacceptable staleness. Combine TTL with write-through or event invalidation when freshness matters.

Can I use in-memory cache in a distributed system?

Only for single-instance or ephemeral cases. In distributed systems use a shared cache (Redis) and an event-based invalidation protocol.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
caching skill by yanko-belov/code-craft | VeilStrat