Optional
blockingOptional
dataUsed for "database" commands to enforce type checking.
Private
loggerMaximum number of parameters allowed. -1 for no maximum.
Minimum number of parameters require.
Optional
pubUsed when PUB/SUB is in effect.
Optional
signSign is used in commands with a compliment command. The only current example is INCR/DECR. Sign is 1 for INCR and -1 for DECR
Optional
txUsed in transactions to enqueue a command.
Static
DEFAULT_Every command must implement the execute method.
Private
getPrivate
getPrivate
getPrivate
set
Available since 2.6.9.
Client supports the following parameters:
CLIENT GETNAME returns the name of the current connection as set by CLIENT SETNAME. Since every new connection starts without an associated name, if no name was assigned a null bulk reply is returned.
Return value:
Bulk string reply: The connection name, or a null bulk reply if no name is set.
Available since 5.0.0.
NOTE THAT THIS IMPLEMENTATION IS NOT AS ROBUST AS IS EXPLAINED BELOW (YET). Intead this implementation will return the ID assigned by the server.
The command just returns the ID of the current connection. Every connection ID has certain guarantees:
It is never repeated, so if CLIENT ID returns the same number, the caller can be sure that the underlying client did not disconnect and reconnect the connection, but it is still the same connection.
The ID is monotonically incremental. If the ID of a connection is greater than the ID of another connection, it is guaranteed that the second connection was established with the server at a later time.
This command is especially useful together with CLIENT UNBLOCK which was introduced also in Redis 5 together with CLIENT ID. Check the CLIENT UNBLOCK command page for a pattern involving the two commands.
CLIENT LIST [TYPE normal|master|replica|pubsub]
Available since 2.4.0.
ONLY PARTIALLY IMPLEMENTED
The CLIENT LIST command returns information and statistics about the client connections server in a mostly human readable format.
As of v5.0, the optional TYPE type subcommand can be used to filter the list by clients' type, where type is one of normal, master, replica and pubsub. Note that clients blocked into the MONITOR command are considered to belong to the normal class.
Return value:
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). name: the name set by the client with CLIENT SETNAME 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:
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 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
Available since 2.6.9.
CLIENT SETNAME command assigns a name to the current connection.
The assigned name is displayed in the output of CLIENT LIST so that it is possible to identify the client that performed a given connection.
For instance when Redis is used in order to implement a queue, producers and consumers of messages may want to set the name of the connection according to their role.
There is no limit to the length of the name that can be assigned if not the usual limits of the Redis string type (512 MB). However it is not possible to use spaces in the connection name as this would violate the format of the CLIENT LIST reply.
It is possible to entirely remove the connection name setting it to the empty string, that is not a valid connection name since it serves to this specific purpose.
The connection name can be inspected using CLIENT GETNAME.
Every new connection starts without an assigned name.
Return value:
Simple string reply: OK if the connection name was successfully set.