skills/smithery.ai/NestJS Caching & Redis

NestJS Caching & Redis

Installation
SKILL.md

Caching & Redis Standards

Caching Strategy

  • Layering: Use Multi-Level Caching for high-traffic read endpoints.
    • L1 (Local): In-Memory (Node.js heap). Ultra-fast, no network. Ideal for config/static data. Use lru-cache.
    • L2 (Distributed): Redis. Shared across pods.
  • Pattern: Implement Stale-While-Revalidate where possible to avoid latency spikes during cache misses.

NestJS Implementation

  • Library: Use cache-manager with cache-manager-redis-yet (Recommended over cache-manager-redis-store for better V4 support and stability).
  • Interceptors: Use @UseInterceptors(CacheInterceptor) for simple GET responses.
    • Warning: By default, this uses the URL as the key. Ensure consistent query param ordering or custom key generators.
  • Decorators: Standardize custom cache keys.
Installs
–
First Seen
–