Available since: 5.0.0
Time complexity: O(1)
The command just returns the ID of the current connection. Every connection ID has certain guarantees:
CLIENT IDreturns 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.
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.
The id of the client.