本文内容为 http://redis.io/commands/client-list 的翻译、注解、例子扩充及其它修改。感谢 Redis 作者 Antirez 为开源社区作出的贡献,本文保证最新、最准、最全以表示对其的敬意。欢迎留言纠错、提示更新或支持。
CLIENT LIST

以比较容易阅读的格式返回客户端与服务端连接的信息及数据。

The CLIENT LIST command returns information and statistics about the client connections server in a mostly human readable format.
  • Bulk string reply: a unique string, formatted as follows:
    • One client connection per line (separated by LF)
    • Each line is composed of a succession of property=value fields separated by a space character.
    Here is the meaning of the fields:
    • id: an unique 64-bit client ID (introduced in Redis 2.8.12).
    • addr: address/port of the client
    • fd: file descriptor corresponding to the socket
    • age: total duration of the connection in seconds
    • 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
    • multi: number of commands in a MULTI/EXEC context
    • qbuf: query buffer length (0 means no query pending)
    • qbuf-free: free space of the query buffer (0 means the buffer is full)
    • obl: output buffer length
    • oll: output list length (replies are queued in this list when the buffer is full)
    • omem: output buffer memory usage
    • 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 (deprecated)
    • d: a watched keys has been modified - EXEC will fail
    • c: connection to be closed after writing entire reply
    • u: the client is unblocked
    • A: connection to be closed ASAP
    • 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)
  • 版本支持

    2.4.0+

    时间复杂度(Time complexity)

    O(N)N 为客户端连接数。

    O(N) where N is the number of client connections

    其它

    新的字段将会不断被加进来,而一些字段在未来也有可能被移除。一个版本安全的 Redis 客户端须根据具体情况来解析输出(如:处理丢失字段,跳过未知字段)。

    New fields are regularly added for debugging purpose. Some could be removed in the future. A version safe Redis client using this command should parse the output accordingly (i.e. handling gracefully missing fields, skipping unknown fields).