Redis 简介

Redis 的特性、应用场景与版本。

Beginner
Key Points单线程模型 + IO 多路复用让 Redis 既简单又极快;6.0 后引入多线程处理网络 IO。

核心特性

  • 基于内存,速度极快
  • 丰富的数据结构(不只是字符串)
  • 原子操作,无需加锁
  • 支持过期、发布订阅、Lua 脚本、事务
  • 主从复制、哨兵、集群高可用

单线程的真相

Redis executes commands on a single thread, so each command is atomic with no locking. It serves tens of thousands of connections via IO multiplexing (epoll). Since 6.0 the network read/write is multi-threaded, but command execution stays single-threaded to preserve atomicity.

Because commands run single-threaded, slow ones like KEYS * or a big HGETALL block the whole server. Never use KEYS in production; use SCAN instead.

Friends & Partners