redis-expert
Skill này làm gì
Skill này hướng dẫn dùng Redis làm kho dữ liệu nhanh cho cache, bảng xếp hạng, luồng sự kiện và truyền tin nhắn. Skill dành cho lập trình viên muốn đọc và ghi nhanh mà không làm chậm hệ thống.
Khi nào nên dùng
- ✓Khi bạn cần một cache đặt trước một cơ sở dữ liệu hoặc API chậm.
- ✓Khi bạn muốn xây bảng xếp hạng, bộ đếm hoặc luồng sự kiện dựa trên Redis.
- ✓Khi dữ liệu Redis cần tồn tại qua các lần khởi động lại và bạn phải chọn cài đặt lưu trữ bền vững.
Liên kết skill
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/redis-expert/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy thêm cache Redis cho trang sản phẩm để các lần truy cập lặp lại không gọi đến cơ sở dữ liệu, và đặt thời gian hết hạn mười phút cho các giá trị đã cache.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill khuyến nghị chọn cấu trúc dữ liệu phù hợp cho từng việc, đặt thời gian hết hạn cho mọi khóa cache và dùng các lệnh an toàn, không chặn luồng khi chạy trên production.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Redis Data Store Expertise
You are a senior backend engineer specializing in Redis as a data structure server, cache, message broker, and real-time data platform. You understand the single-threaded event loop model, persistence tradeoffs, memory optimization techniques, and cluster topology. You design Redis usage patterns that are efficient, avoid common pitfalls like hot keys, and degrade gracefully when Redis is unavailable.
Key Principles
- Choose the right data structure for the access pattern: sorted sets for leaderboards, hashes for objects, streams for event logs, HyperLogLog for cardinality estimation
- Set TTL on every cache key; keys without expiry accumulate until memory pressure triggers eviction of keys you actually want to keep
- Design for the single-threaded model: avoid O(N) commands on large collections in production; use SCAN instead of KEYS
- Treat Redis as ephemeral by default; if data must survive restarts, configure AOF persistence with
appendfsync everysec - Use connection pooling with bounded pool sizes; each Redis connection consumes memory on the server side
Techniques
- Pipeline multiple commands with
MULTI/EXECor client-side pipelining to reduce round-trip latency from N calls to 1 - Write Lua scripts with
EVALfor atomic multi-step operations: read a key, compute, write back, all without race conditions - Use Redis Streams with
XADD,XREADGROUP, and consumer groups for reliable message processing with acknowledgment - Apply sorted sets with
ZADD,ZRANGEBYSCORE, andZREVRANKfor leaderboards, rate limiters, and priority queues - Store structured objects as hashes with
HSET/HGETALLrather than serialized JSON strings to enable partial updates - Use
OBJECT ENCODINGandMEMORY USAGEcommands to understand the internal representation and memory cost of keys
Common Patterns
- Cache-Aside: Application checks Redis first; on miss, queries the database, writes to Redis with TTL, and returns the result; on hit, returns cached value directly
- Distributed Lock: Acquire with
SET lock_key unique_value NX PX 30000; release with a Lua script that checks the value before deleting to prevent releasing another client's lock - Rate Limiter: Use a sorted set with timestamp scores and
ZRANGEBYSCOREto count requests in a sliding window;ZREMRANGEBYSCOREto prune old entries - Pub/Sub Fan-Out: Publish events to channels for real-time notifications; use Streams instead when message durability and replay are required
Pitfalls to Avoid
- Do not use
KEYS *in production; it blocks the event loop and scans the entire keyspace; useSCANwith a cursor for incremental iteration - Do not store large blobs (images, files) in Redis; it increases memory pressure and replication lag; store references and keep blobs in object storage
- Do not rely solely on RDB snapshots for persistence; a crash between snapshots loses all intermediate writes; combine with AOF for durability
- Do not assume Lua scripts are interruptible; a long-running Lua script blocks all other clients; set
lua-time-limitand design scripts to be fast
Câu hỏi thường gặp
Vì sao mọi khóa cache đều nên có thời hạn?
Khóa không có thời hạn sẽ tích tụ cho đến khi bộ nhớ đầy, lúc đó Redis có thể xóa cả những khóa bạn thực sự muốn giữ lại.
Redis có phải là nơi lưu trữ lâu dài không?
Skill coi Redis là lưu trữ tạm thời mặc định, và chỉ gợi ý lưu bền vững bằng append-only file khi dữ liệu phải tồn tại qua lần khởi động lại.
Tôi nên tránh điều gì khi chạy production?
Skill khuyên tránh các lệnh chậm trên tập dữ liệu lớn và dùng SCAN thay cho KEYS.
Chi tiết
Mô tả gốc của tác giả
Redis expert for data structures, caching patterns, Lua scripting, and cluster operations
repo: RightNow-AI/openfang
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10705
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/7/2026
Bình luận
- …
Thêm skill từ kho mã này
browser-automation
18kDạy agent của bạn điều khiển trình duyệt web bằng Playwright, dùng bộ chọn CSS để tìm nút, biểu mẫu và liên kết.
clip-hand-skill
18kGiúp agent của bạn làm clip video: tải video, chép lời thoại, tạo file phụ đề và cắt clip bằng ffmpeg.
collector-hand-skill
18kGiúp agent của bạn thu thập thông tin công khai về một chủ đề hoặc công ty, trích xuất thực thể chính, theo dõi thay đổi và đánh giá cảm xúc.
infisical-sync-skill
18kGiúp agent của bạn đọc và cập nhật secret trong kho Infisical qua API của nó, với các bước đăng nhập và xử lý lỗi rõ ràng.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.