skills/redis-caching/SKILL.md
Redis caching, rate limiting, session storage, pub/sub, and production integration patterns for TypeScript, Next.js, NestJS, and Prisma applications. Use when adding cache-aside or write-through caching, rate limiting, session or lock storage, pub/sub fanout, or reviewing Redis key design and TTLs.
npx skillsauth add shipshitdev/library redis-cachingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Implement Redis as a production support layer, not as a second database.
For BullMQ job queue architecture, use nestjs-queue-architect instead of duplicating queue patterns here.
ioredis.nestjs-queue-architect.app:env:entity:id:variant.bun add ioredis
# Optional serverless Redis
bun add @upstash/redis @upstash/ratelimit
Use one Redis client per process (a module-level singleton guarded against
hot-reload duplication). Do not create a new TCP client per request. Wire
error, connect, and reconnecting events into the app logger or APM. Avoid
logging credentials from connection URLs.
See references/examples.md (§ Redis Client Singleton) for the full setup.
Use cache-aside for reads where brief staleness is acceptable: check the
cache, on miss call the loader, write back with a jittered TTL (baseTtl + random(0, jitter)) so hot keys don't all expire in the same instant.
See references/examples.md (§ Cache-Aside With Prisma) for the getCached
helper and a Prisma-backed usage example.
Protect hot keys with a short SET key val EX 10 NX lock. Only the holder
(matched by a random token) releases it; losers wait briefly and re-check the
cache before falling through to a direct load.
See references/examples.md (§ Stampede Protection) for the full
lock-and-release implementation.
Prefer direct invalidation for known keys. Use tag sets (a Redis set per tag,
mapping to the keys written under it) when one mutation affects many keys —
write through a pipeline, invalidate by reading the tag's key set and
UNLINK-ing them. Use SCAN instead of KEYS for emergency pattern cleanup.
Do not put pattern invalidation on hot request paths.
See references/examples.md (§ Tag-Based Invalidation) for the
cacheSetWithTags / invalidateTag implementation.
Use sorted sets for sliding-window limits when exactness matters: trim
expired entries, add the current request, count members, and set the key's
expiry — all in one MULTI. For public traffic, set response headers:
X-RateLimit-Limit, X-RateLimit-Remaining, and Retry-After.
See references/examples.md (§ Sliding-Window Rate Limiting) for the full
slidingWindowRateLimit implementation.
See references/examples.md (§ Session Storage) for a createSession example.
KEYS, unbounded SMEMBERS, or large HGETALL.development
Coordinates a weekly engineering review of board accuracy, recent code changes, operational health, and scoped cleanup. Use for a recurring repository health review or a review of the last several days.
testing
Audits project board configuration and prepares explicitly requested setup, copy, or normalization changes while preserving the existing workflow and provider boundaries. Use when inspecting a board's fields, columns, scope, or configuration.
testing
Reconciles a project board with current work and delivery evidence, reports incomplete coverage and metadata gaps, and applies only approved provider-supported field changes. Use when auditing board drift, reviewing blocked work, or assessing upcoming delivery.
development
Walk through how a subsystem works. Use for "how does X work", code walkthroughs before changing something, and placement or ownership questions. Explains architecture, runtime flow, and onboarding mental models. Can critique architecture. Use why for motivation.