HELLO
The HELLO command is used to perform a handshake between the Redis server and client. It also allows clients to negotiate the RESP protocol version used and perform authentication.
Redis Native Command Syntax
Section titled “Redis Native Command Syntax”HELLO [protover [AUTH username password] [SETNAME clientname]]Parameter Description
- protover: The RESP protocol version to negotiate (2 or 3)
- AUTH username password: Optional authentication information
- SETNAME clientname: Set client name
Detailed Explanation
Section titled “Detailed Explanation”The HELLO command is a modern handshake command introduced in Redis 6.0, used to replace the old AUTH and SELECT command combination. It provides a standardized way to:
- Negotiate the RESP (Redis Serialization Protocol) version used between client and server
- Perform authentication
- Set client name
RESP Protocol Versions
Section titled “RESP Protocol Versions”Redis supports two RESP protocol versions:
- RESP2: Protocol version introduced in Redis 2.0
- RESP3: Protocol version introduced in Redis 6.0, providing richer data type support
Authentication
Section titled “Authentication”The HELLO command can perform authentication directly during the handshake process, avoiding the need to send AUTH commands separately.
Setting Client Name
Section titled “Setting Client Name”The SETNAME option can be used to set a name for the client connection, facilitating server-side management and monitoring.
Redisun Usage
Section titled “Redisun Usage”In redisun, the HELLO command is implemented through the HelloCommand class, but it usually does not need to be called directly, as the client automatically executes the HELLO command when the connection is established.
Direct Use of HelloCommand
Section titled “Direct Use of HelloCommand”Redisun redisun = new Redisun(); // Using default configuration// The HELLO command will be executed automatically, no manual call neededUsing Authentication
Section titled “Using Authentication”Authentication information is configured through RedisunOptions:
Redisun redisun = Redisun.create(options -> { options.setUsername("myuser"); options.setPassword("mypassword");});- The HELLO command is available in Redis 6.0 and above
- Clients usually automatically execute the HELLO command when the connection is established
- Authentication through the HELLO command is more efficient than using the AUTH command separately