caching

Implement Redis cache-aside patterns with TTL and SCAN deletion.

Updated Apr 16, 2025
One-click install
npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill caching-teexiii
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: caching
Source: https://github.com/teexiii/boilerplate-rest-bun-for-noob/tree/main/.agent/skills/caching
Command: npx skills add https://github.com/teexiii/boilerplate-rest-bun-for-noob --skill caching-teexiii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps teams reduce database load and speed up response times by providing Redis caching patterns, cache-aside workflows, and safe invalidation strategies for application data.

Core Features & Use Cases

  • Cache-aside reads: Try cache first, fallback to the database, and write back in the background to avoid blocking requests.
  • Key namespacing & dual indexing: Consistent hierarchical keys for entities, plus indexing by ID and unique fields such as email.
  • TTL strategies and batching: Per-entity TTL recommendations, non-blocking SCAN-based deletions and batched key removals to avoid blocking Redis.
  • Invalidation patterns: Targeted invalidation, list clearing after mutations, and cascading invalidation across related entities.
  • Reliability & safety: Graceful degradation in local development, non-throwing cache operations, retry/backoff configuration, and atomic operations like setNX.

Quick Start

Perform a cache-aside lookup for user id abc-123, fetch from the database if missing, store the result with a five-minute TTL, and return the user object.

Frequently Asked Questions about caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement Redis caching to speed up my REST API?

Redis caching accelerates REST APIs using the cache-aside pattern: attempt reading from cache first, fall back to the database if missing, then write the result back in the background to reduce database load.

What is the cache-aside pattern and how does it handle background writes?

The cache-aside pattern checks the cache first, retrieves data from the database on a miss, and performs non-blocking background cache writes to store the fetched application data without delaying the current request.

How do I invalidate Redis cache keys without blocking the database?

Invalidate Redis cache keys using non-blocking SCAN-based deletions and batched key removals, applying targeted invalidation and list clearing after data mutations to avoid blocking Redis operations.

What TTL strategies should I use for Redis caching on user and activity entities?

Apply per-entity TTL strategies for Redis caching on user and activity entities, setting distinct expiration times for cached data to balance freshness with performance for read-heavy REST services.

Does Redis caching support graceful degradation for local development environments?

Redis caching supports graceful degradation in local development through non-throwing cache operations, allowing your application to function normally when the cache is unavailable without throwing errors.

What's the best way to namespace Redis keys for multiple entity types?

The best way to namespace Redis keys for multiple entity types is using consistent hierarchical keys, plus dual indexing by ID and unique fields such as email to maintain organized cache lookups.