CLIENT LIST

语法
CLIENT LIST [TYPE <NORMAL | MASTER | REPLICA | PUBSUB>]
  [ID client-id [client-id ...]]
可用版本
Redis Open Source 2.4.0
时间复杂度
O(N),其中 N 是客户端连接数
ACL 类别
@admin, @slow, @dangerous, @connection,

CLIENT LIST 命令返回服务器上客户端连接的信息和统计数据,格式多数情况下易于人类阅读。

您可以使用可选的子命令之一来过滤列表。TYPE type 子命令按客户端类型过滤列表,其中 typenormal, master, replicapubsub 之一。请注意,被 MONITOR 命令阻塞的客户端属于 normal 类。

ID 过滤器仅返回 ID 与 client-id 参数匹配的客户端条目。

以下是字段的含义

  • id: 唯一的 64 位客户端 ID
  • addr: 客户端的地址/端口
  • laddr: 客户端连接到的本地地址/端口(绑定地址)
  • fd: 对应于套接字的文件描述符
  • name: 客户端使用 CLIENT SETNAME 设置的名称
  • age: 连接的总持续时间(秒)
  • idle: 连接的空闲时间(秒)
  • flags: 客户端标志(见下文)
  • db: 当前数据库 ID
  • sub: 频道订阅数
  • psub: 模式匹配订阅数
  • ssub: 分片频道订阅数。在 Redis 7.0.3 中添加
  • multi: MULTI/EXEC 上下文中的命令数
  • watch: 此客户端当前正在监视的键数。在 Redis 7.4 中添加
  • qbuf: 查询缓冲区长度(0 表示没有待处理的查询)
  • qbuf-free: 查询缓冲区的可用空间(0 表示缓冲区已满)
  • argv-mem: 下一个命令的不完整参数(已从查询缓冲区中提取)
  • multi-mem: 缓冲的多命令使用的内存。在 Redis 7.0 中添加
  • obl: 输出缓冲区长度
  • oll: 输出列表长度(当缓冲区满时,回复在此列表中排队)
  • omem: 输出缓冲区内存使用情况
  • tot-mem: 此客户端在其各种缓冲区中消耗的总内存
  • events: 文件描述符事件(见下文)
  • cmd: 执行的最后一条命令
  • user: 客户端的已认证用户名
  • redir: 当前客户端跟踪重定向的客户端 id
  • resp: 客户端 RESP 协议版本。在 Redis 7.0 中添加
  • rbp: 客户端连接以来其读取缓冲区的峰值大小。在 Redis 7.0 中添加
  • rbs: 客户端读取缓冲区当前大小(字节)。在 Redis 7.0 中添加
  • io-thread: 分配给客户端的 I/O 线程 ID。在 Redis 8.0 中添加

客户端标志可以是以下组合

A: connection to be closed ASAP
b: the client is waiting in a blocking operation
c: connection to be closed after writing entire reply
d: a watched keys has been modified - EXEC will fail
e: the client is excluded from the client eviction mechanism
i: the client is waiting for a VM I/O (deprecated)
M: the client is a master
N: no specific flag set
O: the client is a client in MONITOR mode
P: the client is a Pub/Sub subscriber
r: the client is in readonly mode against a cluster node
S: the client is a replica node connection to this instance
u: the client is unblocked
U: the client is connected via a Unix domain socket
x: the client is in a MULTI/EXEC context
t: the client enabled keys tracking in order to perform client side caching
T: the client will not touch the LRU/LFU of the keys it accesses
R: the client tracking target client is invalid
B: the client enabled broadcast tracking mode 

文件描述符事件可以是

r: the client socket is readable (event loop)
w: the client socket is writable (event loop)

注意

为了调试目的,定期添加新的字段。有些未来可能会被移除。使用此命令的版本安全的 Redis 客户端应相应地解析输出(即优雅地处理缺失的字段,跳过未知的字段)。

RESP2/RESP3 回复

Bulk string 回复:关于客户端连接的信息和统计数据。

历史

  • 自 Redis 2.8.12 版本起:添加了唯一的客户端 id 字段。
  • 自 Redis 5.0.0 版本起:添加了可选的 TYPE 过滤器。
  • 自 Redis 6.0.0 版本起:添加了 user 字段。
  • 自 Redis 6.2.0 版本起:添加了 argv-mem, tot-mem, laddrredir 字段以及可选的 ID 过滤器。
  • 自 Redis 7.0.0 版本起:添加了 resp, multi-mem, rbsrbp 字段。
  • 自 Redis 7.0.3 版本起:添加了 ssub 字段。
给本页评分
返回顶部 ↑