4.7 KiB
]
INFO
What it does
Returns server stats in a human-readable text block, optionally filtered by sections. Typical sections: server, clients, memory, persistence, stats, replication, cpu, commandstats, latencystats, cluster, modules, keyspace, errorstats. Special args: all, default, everything. The reply is a Bulk String with # <Section> headers and key:value lines. (Redis)
Syntax
INFO [section [section ...]]
Return (RESP2/RESP3): Bulk String. (Redis)
RESP request/response
# Request: whole default set
*1\r\n$4\r\nINFO\r\n
# Request: a specific section, e.g., clients
*2\r\n$4\r\nINFO\r\n$7\r\nclients\r\n
# Response (prefix shown; body is long)
$1234\r\n# Server\r\nredis_version:7.4.0\r\n...\r\n# Clients\r\nconnected_clients:3\r\n...\r\n
(Reply type/format per RESP spec and the INFO page.) (Redis)
Connection “name” (there is no top-level NAME command)
Redis doesn’t have a standalone NAME command. Connection names are handled via CLIENT SETNAME and retrieved via CLIENT GETNAME. (Redis)
CLIENT SETNAME
Assigns a human label to the current connection (shown in CLIENT LIST, logs, etc.). No spaces allowed in the name; empty string clears it. Length is limited by Redis string limits (practically huge). Reply: Simple String OK. (Redis)
Syntax
CLIENT SETNAME connection-name
RESP
# Set the name "myapp"
*3\r\n$6\r\nCLIENT\r\n$7\r\nSETNAME\r\n$5\r\nmyapp\r\n
# Reply
+OK\r\n
CLIENT GETNAME
Returns the current connection’s name or Null Bulk String if unset. (Redis)
Syntax
CLIENT GETNAME
RESP
# Before SETNAME:
*2\r\n$6\r\nCLIENT\r\n$7\r\nGETNAME\r\n
$-1\r\n # nil (no name)
# After SETNAME myapp:
*2\r\n$6\r\nCLIENT\r\n$7\r\nGETNAME\r\n
$5\r\nmyapp\r\n
(Null/Bulk String encoding per RESP spec.) (Redis)
CLIENT (container command + key subcommands)
CLIENT is a container; use subcommands like CLIENT LIST, CLIENT INFO, CLIENT ID, CLIENT KILL, CLIENT TRACKING, etc. Call CLIENT HELP to enumerate them. (Redis)
CLIENT LIST
Shows all connections as a single Bulk String: one line per client with field=value pairs (includes id, addr, name, db, user, resp, and more). Filters: TYPE and ID. Return: Bulk String (RESP2/RESP3). (Redis)
Syntax
CLIENT LIST [TYPE <NORMAL|MASTER|REPLICA|PUBSUB>] [ID client-id ...]
RESP
*2\r\n$6\r\nCLIENT\r\n$4\r\nLIST\r\n
# Reply (single Bulk String; example with one line shown)
$188\r\nid=7 addr=127.0.0.1:60840 laddr=127.0.0.1:6379 fd=8 name=myapp age=12 idle=3 flags=N db=0 ...\r\n
CLIENT INFO
Returns info for this connection only (same format/fields as a single line of CLIENT LIST). Return: Bulk String. Available since 6.2.0. (Redis)
Syntax
CLIENT INFO
RESP
*2\r\n$6\r\nCLIENT\r\n$4\r\nINFO\r\n
$160\r\nid=7 addr=127.0.0.1:60840 laddr=127.0.0.1:6379 fd=8 name=myapp db=0 user=default resp=2 ...\r\n
RESP notes you’ll need for your parser
- Requests are Arrays:
*N\r\nfollowed byNBulk Strings for verb/args. - Common replies here: Simple String (
+OK\r\n), Bulk String ($<len>\r\n...\r\n), and Null Bulk String ($-1\r\n). (These coverINFO,CLIENT LIST/INFO,CLIENT GETNAME,CLIENT SETNAME.) (Redis)
Sources (checked)
- INFO command (syntax, sections, behavior). (Redis)
- RESP spec (request/response framing, Bulk/Null Bulk Strings). (Redis)
- CLIENT container + subcommands index. (Redis)
- CLIENT LIST (fields, bulk-string return, filters). (Redis)
- CLIENT INFO (exists since 6.2, reply format). (Redis)
- CLIENT SETNAME (no spaces; clears with empty string; huge length OK). (Redis)
- CLIENT GETNAME (nil if unset). (Redis)
If you want, I can fold this into a tiny Rust “command + RESP” test harness that exercises INFO, CLIENT SETNAME/GETNAME, CLIENT LIST, and CLIENT INFO against your in-mem RESP parser.