Redis Client List 命令用于返回所有连接到服务器的客户端信息和统计数据。

语法

redis Client List 命令基本语法如下:

  1. redis 127.0.0.1:6379> CLIENT LIST

可用版本

= 2.4.0


返回值

命令返回多行字符串,这些字符串按以下形式被格式化:

每个已连接客户端对应一行(以 LF 分割)

每行字符串由一系列 属性=值 形式的域组成,每个域之间以空格分开

以下是域的含义:

属性 说明
id : 唯一的64位客户端ID
name: 客户端用CLIENT SETNAME设置的名称。
addr : 客户端的地址和端口
laddr: 客户端连接的本地地址/端口(绑定地址)。
fd : 套接字所使用的文件描述符
age : 以秒计算的已连接时长
idle : 以秒计算的空闲时长
flags : 客户端 flag(见下文表格)
db : 该客户端正在使用的数据库 ID
sub : 已订阅频道的数量
psub : 已订阅模式的数量
multi : 在事务中被执行的命令数量
qbuf : 查询缓冲区的长度(字节为单位, 0 表示没有分配查询缓冲区)
qbuf-free: 查询缓冲区剩余空间的长度(字节为单位, 0 表示没有剩余空间)
obl : 输出缓冲区的长度(字节为单位, 0 表示没有分配输出缓冲区)
oll : 输出列表包含的对象数量(当输出缓冲区没有剩余空间时,命令回复会以字符串对象的形式被入队到这个队列里)
omem : 输出缓冲区和输出列表占用的内存总量
events : 文件描述符事件(见下文表格)
cmd : 最近一次执行的命令
argv-mem: 下一条命令的不完整参数(已从查询缓冲区中提取)。
tot-mem: 该客户端在各种缓冲区中消耗的总内存。
redir: 当前客户跟踪重定向的客户ID。
user: 客户端经过认证的用户名

客户端 flag 可以由以下部分组成:

flag值 说明
A: 连接要尽快关闭
b: 客户端正在等待阻断操作。
c: 写完整个回复后关闭连接。
d: 一个被监视的密钥被修改了 - EXEC 将失败。
i: 客户端正在等待一个虚拟机I/O(已废弃)。
M: 客户端是主节点(master
N: 没有设置具体的标志
O: 客户机是MONITOR模式下的客户机。
P: 客户端是Pub/Sub订阅者
r: 客户端对集群节点处于只读模式。
S: 客户机是复制节点连接到这个实例的。
u: 客户端已被解封
U: 客户机通过Unix域套接字连接。
x: 客户机处于MULTI/EXEC上下文中。
t: 客户端启用了密钥跟踪,以执行客户端缓存。
R: 客户跟踪目标客户无效
B: 客户端启用广播跟踪模式

文件描述符事件可以是:

属性 说明
r : 客户端套接字(在事件 loop 中)是可读的(readable
w : 客户端套接字(在事件 loop 中)是可写的(writeable

说明

为了调试的目的,会定期增加新的字段。一些字段可能会在将来被删除。使用此命令的版本安全的Redis客户端应该对输出进行相应的解析(例如,处理优雅的缺失字段,跳过未知字段)。

历史记录

= 2.8.12: 增加了唯一的客户端字段.id。 = 5.0: 增加了可选的TYPE过滤器。 = 6.2: 增加了字段和可选的filter.laddrID。

实例

  1. localhost:0>CLIENT LIST
  2. "id=12 addr=127.0.0.1:4168 fd=9 name= age=2181 idle=0 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=replconf
  3. id=17 addr=127.0.0.1:4945 fd=10 name= age=1837 idle=1837 flags=N db=0 sub=0 psub=1 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=psubscribe
  4. id=18 addr=127.0.0.1:4946 fd=13 name= age=1837 idle=1 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=info
  5. id=19 addr=127.0.0.1:8598 fd=12 name= age=3 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
  6. "
  1. RDM Redis Console
  2. 连接中...
  3. 已连接。
  4. CuiHuaPro:0>CLIENT LIST
  5. "id=42091595 addr=172.31.66.0:49274 fd=18 name=CHKMWXSERVICES age=836985 idle=3 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  6. id=42126425 addr=172.31.66.0:61064 fd=63 name=CHKMWXSERVICES age=801045 idle=25 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  7. id=42873276 addr=172.31.66.1:62599 fd=49 name=CHKMWXWEB age=29132 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  8. id=42126426 addr=172.31.66.0:61065 fd=64 name=CHKMWXSERVICES age=801045 idle=25 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  9. id=42126423 addr=172.31.66.0:61062 fd=61 name=CHKMWXSERVICES age=801045 idle=26 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  10. id=42126424 addr=172.31.66.0:61063 fd=62 name=CHKMWXSERVICES age=801045 idle=26 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  11. id=42112259 addr=172.31.66.1:58026 fd=50 name=CHKMWXWEB age=815685 idle=4 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  12. id=42112260 addr=172.31.66.1:58027 fd=51 name=CHKMWXWEB age=815685 idle=4 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  13. id=42105531 addr=172.31.66.0:54843 fd=41 name=CHKMWXSERVICES age=822633 idle=27 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  14. id=42105532 addr=172.31.66.0:54844 fd=42 name=CHKMWXSERVICES age=822633 idle=12 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  15. id=42854949 addr=172.31.66.0:64394 fd=36 name=CHKMWXSERVICES age=48043 idle=27 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  16. id=42854950 addr=172.31.66.0:64395 fd=45 name=CHKMWXSERVICES age=48043 idle=0 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=set type=user next_opid=-1
  17. id=42890826 addr=172.31.66.1:54330 fd=70 name= age=11010 idle=0 flags=P db=0 sub=0 psub=1 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=psubscribe type=user next_opid=-1
  18. id=42890827 addr=172.31.66.1:54331 fd=71 name= age=11010 idle=5 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  19. id=42842175 addr=172.31.66.1:52322 fd=46 name=CHKMWXWEB age=61230 idle=14 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  20. id=42857016 addr=172.31.66.1:57483 fd=16 name=CHKMWXWEB age=45916 idle=0 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=setex type=user next_opid=-1
  21. id=42857017 addr=172.31.66.1:57484 fd=29 name=CHKMWXWEB age=45916 idle=14 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  22. id=42842176 addr=172.31.66.1:52323 fd=65 name=CHKMWXWEB age=61230 idle=44 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  23. id=42091991 addr=172.31.66.0:49687 fd=21 name=CHKMWXSERVICES age=836587 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=del type=user next_opid=-1
  24. id=42091992 addr=172.31.66.0:49688 fd=22 name=CHKMWXSERVICES age=836587 idle=30 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  25. id=42856125 addr=172.31.66.1:57159 fd=23 name=CHKMWXWEB age=46838 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  26. id=42856126 addr=172.31.66.1:57160 fd=25 name=CHKMWXWEB age=46838 idle=4 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  27. id=42901097 addr=172.31.66.1:51889 fd=35 name=CHKMWXWEB age=645 idle=39 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  28. id=42901098 addr=172.31.66.1:51890 fd=38 name=CHKMWXWEB age=645 idle=39 flags=P db=0 sub=4 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  29. id=42856124 addr=172.31.66.1:57156 fd=20 name=CHKMWXWEB age=46838 idle=18 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  30. id=42091901 addr=172.31.66.0:49616 fd=28 name=CHKMWXSERVICES age=836675 idle=13 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  31. id=42875404 addr=172.31.66.0:54298 fd=34 name=CHKMWXSERVICES age=26937 idle=42 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  32. id=42091902 addr=172.31.66.0:49617 fd=30 name=CHKMWXSERVICES age=836675 idle=58 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  33. id=42105525 addr=172.31.66.0:54835 fd=39 name=CHKMWXSERVICES age=822637 idle=16 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  34. id=42105526 addr=172.31.66.0:54836 fd=40 name=CHKMWXSERVICES age=822637 idle=31 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  35. id=42091678 addr=172.31.66.0:49359 fd=26 name=CHKMWXSERVICES age=836907 idle=6 flags=N db=2 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  36. id=42875403 addr=172.31.66.0:54297 fd=19 name=CHKMWXSERVICES age=26937 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  37. id=42860501 addr=172.31.66.0:49813 fd=14 name=CHKMWXSERVICES age=42320 idle=5 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  38. id=42901722 addr=172.31.66.1:52425 fd=60 name= age=8 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=client type=user next_opid=-1
  39. id=42860502 addr=172.31.66.0:49812 fd=15 name=CHKMWXSERVICES age=42320 idle=5 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  40. id=42091679 addr=172.31.66.0:49360 fd=27 name=CHKMWXSERVICES age=836907 idle=21 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  41. id=42854957 addr=172.31.66.0:64398 fd=57 name=CHKMWXSERVICES age=48039 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  42. id=42854958 addr=172.31.66.0:64399 fd=58 name=CHKMWXSERVICES age=48039 idle=38 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  43. id=42091594 addr=172.31.66.0:49273 fd=13 name=CHKMWXSERVICES age=836985 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=set type=user next_opid=-1
  44. id=42867193 addr=172.31.66.0:51812 fd=43 name=CHKMWXSERVICES age=35408 idle=47 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  45. id=42893084 addr=172.31.66.1:56882 fd=55 name=CHKMWXWEB age=8762 idle=32 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  46. id=42893085 addr=172.31.66.1:56881 fd=59 name=CHKMWXWEB age=8762 idle=47 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=info type=user next_opid=-1
  47. id=42867194 addr=172.31.66.0:51813 fd=47 name=CHKMWXSERVICES age=35408 idle=53 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  48. id=42856121 addr=172.31.66.1:57152 fd=9 name=CHKMWXWEB age=46838 idle=1 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  49. id=42856122 addr=172.31.66.1:57153 fd=17 name=CHKMWXWEB age=46838 idle=18 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  50. id=42868966 addr=172.31.66.1:61275 fd=11 name=CHKMWXWEB age=33578 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  51. id=42879594 addr=172.31.66.1:64793 fd=48 name=CHKMWXWEB age=22602 idle=27 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  52. id=42879595 addr=172.31.66.1:64792 fd=52 name=CHKMWXWEB age=22602 idle=5 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  53. id=42868967 addr=172.31.66.1:61276 fd=31 name=CHKMWXWEB age=33578 idle=52 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  54. id=42092149 addr=172.31.66.1:49243 fd=32 name=CHKMWXWEB age=836441 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  55. id=42854955 addr=172.31.66.0:64397 fd=53 name=CHKMWXSERVICES age=48039 idle=39 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  56. id=42854956 addr=172.31.66.0:64396 fd=56 name=CHKMWXSERVICES age=48039 idle=2 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=get type=user next_opid=-1
  57. id=42092150 addr=172.31.66.1:49244 fd=33 name=CHKMWXWEB age=836441 idle=22 flags=P db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r traffic-control=NULL cmd=unsubscribe type=user next_opid=-1
  58. "
  59. CuiHuaPro:0>

AliyunRedis:0>CLIENT LIST
"id=70845 addr=192.168.178.187:49426 fd=58 name=iZ2wbm98fj0ddsZ age=183629 idle=14 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=INFO
id=70846 addr=192.168.178.187:49427 fd=66 name=iZ2wbm98fj0ddsZ age=183629 idle=14 flags=P db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=UNSUBSCRIBE
id=207466 addr=192.168.178.186:53818 fd=65 name=iZ2wbm98fj0dduZ age=116840 idle=4 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=DEL
id=355132 addr=192.168.178.187:55249 fd=37 name=iZ2wbm98fj0ddsZ age=45204 idle=9 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=INFO
id=355142 addr=192.168.178.185:50592 fd=49 name=iZ2wbm98fj0ddvZ age=45201 idle=3 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=GET
id=355148 addr=192.168.178.187:55279 fd=51 name=iZ2wbm98fj0ddsZ age=45200 idle=5 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=INFO
id=355163 addr=192.168.178.185:50611 fd=54 name=iZ2wbm98fj0ddvZ age=45193 idle=6 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=GET
id=355634 addr=192.168.178.184:60719 fd=62 name=iZ2wbm98fj0ddtZ age=44966 idle=11 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=INFO
id=448371 addr=192.168.178.185:63857 fd=74 name= age=13 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events= cmd=CLIENT
"
AliyunRedis:0>

原文链接

https://redis.io/commands/client-list https://www.redis.net.cn/order/3657.html