AGENT SKILL

redis-pro

Redis data structures, caching strategies, and production operations — use when adding caching, queues, or rate limiting with Redis.

License 许可
MIT
所属仓库
TanNhatCMS/jarvis
最近更新
2026-11-07
Stars
★ 0
Forks
1

01 前言 Front Matter

name
redis-pro
category
database
description
Redis data structures, caching strategies, and production operations — use when adding caching, queues, or rate limiting with Redis.

03 SKILL.md 正文

Overview

Redis is an in-memory data structure server: strings, hashes, lists, sets, sorted sets, streams, and more — each with atomic operations that make it far more than "a cache". This skill covers choosing the right structure, cache patterns, persistence trade-offs, and running Redis reliably.

When to use

  • Designing a cache layer (cache-aside, write-through, TTLs)
  • Building rate limiters, leaderboards, queues, or pub/sub with Redis
  • Choosing persistence (RDB snapshots vs AOF) and eviction policies
  • Debugging memory growth, latency spikes, or key-space problems
  • Using Redis Streams, probabilistic structures (HyperLogLog, Bloom), or Lua scripts

Core concepts

Pick the structure for the operation. Counters → INCR on strings. Objects with field access → hashes (HGET/HSET) to avoid serializing whole blobs. Leaderboards → sorted sets (ZADD/ZRANGE with scores). Queues → lists (LPUSH/BRPOP) or Streams for durable consumer groups. Time-series-ish expiring data → keys with TTL. The wrong structure turns O(1) ops into O(N).

Cache invalidation is the hard part. Cache-aside (read-through on miss, write around or through on update) is the default. Set explicit TTLs even when you invalidate on write — TTLs are your safety net against stale data when invalidation fails. For thundering-herd protection on hot keys, use request coalescing or short stale-while-revalidate windows.

Single-threaded means slow commands hurt everyone. KEYS *, SMEMBERS on huge sets, and SORT without STORE block the event loop. Use SCAN with COUNT for iteration, and keep Lua scripts short — they execute atomically and block everything while running.

Persistence is a spectrum. RDB snapshots are compact and fast to restore but lose recent writes on crash. AOF logs every write (durable, larger, slower rewrites). Many cache-only deployments disable persistence entirely and treat Redis as ephemeral — a valid choice if the source of truth is elsewhere.

Eviction policies. noeviction (error on full — for non-cache uses), allkeys-lru / volatile-lru (classic cache behavior), allkeys-lfu. Match the policy to the workload; the wrong one evicts hot keys or errors under load.

Practical workflow

  1. Define the access pattern (read/write ratio, key lifetime, consistency needs) before choosing structures or TTLs.
  2. Namespace keys (service:entity:id) and keep values small — huge values waste memory and network; consider hashes or splitting.
  3. Set TTLs everywhere for cache data; monitor expired_keys and evicted_keys in INFO stats to confirm expiry behaves as expected.
  4. Load-test the slow path: benchmark SCAN iterations, Lua scripts, and large ZRANGE calls under realistic data sizes.
  5. Monitor memory: INFO memory (used vs peak, fragmentation ratio), MEMORY USAGE <key> for suspicious keys, and --bigkeys sampling to find offenders.
  6. Plan failover: Redis Sentinel or Cluster for HA; test failover before you need it; decide whether clients tolerate brief write loss during failover.

Common pitfalls

  • No TTL on cache keys — memory grows forever until eviction or OOM; always bound key lifetime.
  • Storing sessions or critical data in Redis with no persistence and no fallback — a restart wipes everything; know what "ephemeral" costs you.
  • Hot keys on Cluster — one extremely hot key lands on one shard; mitigate with local client-side caching or key sharding (key:{shard}:...).
  • Blocking commands in request paths (BLPOP with long timeouts, SUBSCRIBE in a web worker) — tie up connections; use dedicated connections for blocking/pub-sub use.
  • Lua scripts that loop over unbounded data — atomicity means the whole server waits; bound the work or move it client-side.
  • Assuming DEL/EXPIRE are instant on huge values — in older versions deleting multi-MB values blocks; use UNLINK (non-blocking delete) for large keys.

04 同仓库更多 Skills

TanNhatCMS
TanNhatCMS/jarvis

web-scrape

Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

design-taste-frontend

tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.

★ 0
TanNhatCMS
TanNhatCMS/jarvis

test-driven-development

Use when implementing any feature or bugfix, before writing implementation code

★ 0
TanNhatCMS
TanNhatCMS/jarvis

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

★ 0
TanNhatCMS
TanNhatCMS/jarvis

requesting-code-review

Use when completing tasks, implementing major features, or before merging to verify work meets requirements

★ 0
TanNhatCMS
TanNhatCMS/jarvis

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

★ 0