Agent skill · software engineering · affaan-m
redis-patterns
Redisデータ構造パターン、キャッシング戦略、分散ロック、レート制限、Pub/Sub、本番アプリケーション用コネクション管理。
Why this skill is useful
Provides specific Redis caching strategies and Lua scripts for rate limiting that are not commonly known.
What it needs
Requires redis installed locally. About 5k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Redis Patterns 一般的なバックエンド使用例に対するRedisベストプラクティスの参考資料。 How It Works Redisはメモリ内データ構造ストアで、文字列、ハッシュ、リスト、セット、ソート済みセット、ストリームなどをサポートします。単一インスタンスでは個々のRedisコマンドは原子的ですが、マルチステップワークフローはLuaスクリプト、MULTI/EXECトランザクション、または明示的な同期化が必要です。RDBスナップショットまたはAOFログを通じてデータをオプションで永続化します。クライアントはRESPプロトコルを使用してTCP経由で通信します。接続プール不可欠でリクエストごとのハンドシェイクオーバーヘッドを回避します。 When to Activate アプリケーションにキャッシング追加 レート制限またはスロットリング実装 分散ロックまたはコーディネーション構築 セッションまたはトークンストレージ設定 Pub/SubまたはRedis Streams for messaging使用 本番環境でRedis設定(プール、削除、クラスタリング) Data Structure Cheat Sheet Use Case Structure Example Key ---------- ----------- ------------- Simple cache String product:123 User session Hash session:abc Leaderboard Sorted Set scores:weekly Unique visitors Set visitors:2024-01-01 Activity feed List feed:user:456 Event stream Stream events:orders Counters / rate limits String (INCR) ratelimit:user:123 Bloom filter / HLL HyperLogLog hll:pageviews Core Patterns Cache-Aside (Lazy Loading) Write-Through Cache Cache Invalidation Session Storage Rate Limiting Fixed Window (Simple) Sliding Window (Lua — Atomic) Distributed Locks Distributed Lock (Single Node — SET NX PX) マルチノード設定の場合、フルRedlockアルゴリズムを実装する redlock-py ライブラリを使用してください。 Pub/Sub & Streams Pub/Sub (Fire-and-Forget) Redis Streams (Durable Queue) 配信保証、コンシューマーグループ、または再生が必要な場合、Pub/Sub代わりにStreamsを優先してください。 Key Design Naming Conventions TTL Strategy Data Type Suggested TTL ----------- -------------- User session 24h (86400) API response cache 5–15 min Rate limit window Match window size Short-lived tokens 5–10 min Leaderboard 1h–24h Static/reference data 1h–1 week 常にTTLを設定してください。TTLなしのキーは無限に蓄積してメモリ圧力を引き起こします。 Connection Management Connection Pooling Cluster Mode Sentinel (High Availability) Eviction Policies Policy Behavior Best For -------- ---------- ---------- noeviction Error on write when full Queues / critical data allkeys-lru Evict least recently used General cache volatile-lru LRU only among keys with TTL Mixed data store allkeys-lfu Evict least frequently used Skewed access patt …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/redis-patterns--bfd0d5