CLIENT SETNAME connection-name

    Time complexity: O(1)

    The command assigns a name to the current 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.

    The connection name can be inspected using .

    Every new connection starts without an assigned name.

    Simple string reply: if the connection name was successfully set.