Trung BìnhDatabase iconDatabase

Redis là gì? Use cases phổ biến của Redis?

Redis là in-memory data store đa dụng — Sorted Set cho leaderboard, List cho queue, Pub/Sub cho real-time, Streams cho event sourcing; RDB+AOF kết hợp cho persistence tốt nhất.

  • Redis là in-memory data store với rich data structures và persistence tùy chọn.
  • Data structure use cases cụ thể: Sorted Set (ZADD, ZRANGE) cho leaderboard — score tự động sorted, query top-N O(log N); Pub/Sub (SUBSCRIBE, PUBLISH) cho real-time notifications và chat; List (LPUSH/RPOP) cho job queue hoặc activity feed; HyperLogLog cho approximate unique count với fixed memory; Streams (XADD, XREAD) cho event sourcing, message queue có consumer groups.
  • Persistence: RDB (snapshot tại intervals — nhanh hơn cho restart, có thể mất data nếu crash giữa snapshots); AOF (Append-Only File — log mọi write operation, recovery tốt hơn nhưng file lớn hơn); RDB+AOF kết hợp cho best of both worlds.
  • Redis Cluster: horizontal sharding tự động với 16384 hash slots, minimum 3 master nodes — đảm bảo availability khi node fail.
  • Redis Sentinel: high availability cho single-master setup với automatic failover.

Xem toàn bộ Database cùng filter theo level & chủ đề con.

Mở danh sách Database