客户端列表

Syntax
CLIENT LIST [TYPE <NORMAL | MASTER | REPLICA | PUBSUB>]
  [ID client-id [client-id ...]]
Available since:
2.4.0
Time complexity:
O(N) where N is the number of client connections
ACL categories:
@admin, @slow, @dangerous, @connection,

CLIENT LIST 命令以大部分人类可读的格式返回有关客户端连接服务器的信息和统计信息。

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

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 中添加

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

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 reply: information and statistics about client connections.

历史

  • 从 Redis 版本 2.8.12 开始:添加了唯一的客户端 id 字段。
  • 从 Redis 5.0.0 版本开始:添加了可选的 TYPE 过滤器。
  • 从 Redis 版本 6.0.0 开始:添加了 user 字段。
  • 从 Redis 6.2.0 版本开始:添加了 argv-memtot-memladdrredir 字段以及可选的 ID 过滤器。
  • 从 Redis 7.0.0 版本开始:添加了 respmulti-memrbsrbp 字段。
  • 从 Redis 版本 7.0.3 开始:添加了 ssub 字段。
RATE THIS PAGE
Back to top ↑