Redis “Client List” purpose and description

2020-07-22 09:07发布

问题:

While executing the "Client List" i get the below result,whats the meaning of the each flag

Slave addr=100.0.0.0:0000 fd=5 idle=3 flags=S db=0 sub=0 psub=0 qbuf=0 obl=0 oll=0 events=r cmd=sync

Master addr=100.0.0.0:0000 fd=6 idle=0 flags=N db=0 sub=0 psub=0 qbuf=0 obl=0 oll=0 events=r cmd=client

回答1:

With client list, Redis prints one row per connected client. From the redis.h and networking.c files of Redis source code:

  • addr: address/port of the client
  • fd: file descriptor corresponding to the socket
  • idle: idle time of the connection in seconds
  • flags: client flags (see below)
  • db: current database ID
  • sub: number of channel subscriptions
  • psub: number of pattern matching subscriptions
  • qbuf: query buffer length (0 means no query pending)
  • obl: output buffer length
  • oll: output list length (replies are queued in this list when the buffer is full)
  • events: file descriptor events (see below)
  • cmd: last command played

The client flags can be a combination of:

  • O: the client is a slave in MONITOR mode
  • S: the client is a normal slave server
  • M: the client is a master
  • x: the client is in a MULTI/EXEC context
  • b: the client is waiting in a blocking operation
  • i: the client is waiting for a VM I/O
  • d: a watched keys has been modified - EXEC will fail
  • c: connection to be closed after writing entire reply
  • u: the client is unblocked
  • N: no specific flag set

The file descriptor events can be:

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

It is my interpretation, please take it with a grain of salt.



标签: redis