hello
HELLO
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Select the Redis output protocol (format)
You can select (set) or inspect the protocol between the Redis server and the client.
RESP(REdis Serialization Protocol) is the output protocol between the Redis server and the client (from the server's point of view).
From Redis version 6, RESP3 was newly added (newly developed).
Up to Redis version 5, only RESP2 existed.
Even in Redis version 6, clients still connect with RESP2 by default.
The HELLO command can show the current RESP version and can select a RESP version. The RESP version is applied per client. That is, only the client that ran HELLO 3 uses RESP3.
The following example shows that the result looks different in RESP 3. This is not applied to the whole server; each client can choose.
Example
| Command> | HELLO |
| Result> |
1) "server" 2) "redis/redisGate Enterprise" 3) "version" 4) "8.0.0" 5) "proto" 6) (integer) 2 7) "id" 8) (integer) 3 9) "mode" 10) "standalone/sentinel/cluster/clone(Active-Active)" 11) "role" 12) "master" 13) "modules" 14) (empty array) |
| Command> | HELLO 3 |
| Result> |
1# "server" => "redisGate Enterprise" 2# "version" => "8.0.0" 3# "proto" => (integer) 3 4# "id" => (integer) 3 5# "mode" => "clone(Active-Active)" 6# "role" => "master" 7# "modules" => (empty array) |
| Command> | hgetall myhash |
| Result> |
1# "field1" => "value1" 2# "field2" => "value2" |
| Command> | zrange key 0 -1 withscores |
| Result> |
1) 1) "value10" 2) (double) 10 2) 1) "value11" 2) (double) 11 3) 1) "value12" 2) (double) 12 4) 1) "value13" 2) (double) 13 |
|
On a redisGate Enterprise server it is displayed as follows. 1# "server" => "redisGate Enterprise" 5# "mode" => "clone(Active-Active)" |
RESP2
RESP2 supports 5 types.
- Status(+): simple return message
- Error(-): error message
- Integer(:): integer
- Bulk($): value (binary-safe: a string that is safe even with special characters)
- Multibulk(*): array marker (shows the number of values)
In RESP2, both keys and values are shown as bulk.
When showing multiple keys and values as an array, put multibulk(*) and the value count at the front,
then show each value as bulk($).
Example) If lrange mylist 0 -1 returns 3 values,
Integer(:) is used for commands that return an integer exactly.
Example) llen, scard, strlen, incr, decr, incrby, decrby, etc.
The incrbyfloat command uses bulk.
RESP3
RESP3 grew to 13 types.
For protocol compatibility, the 5 RESP2 types are kept unchanged.
Notable additions include Null, Boolean, Double, Set, and Map.
The 8 added types are briefly described below.
- Null(_): null marker
- Boolean(#): true/false
- Double(,): floating point number
- Blob error(!): binary-safe error
- Big number((): very large integer, e.g. 3492890328409238509324850943850943825024385
- Set(~): set
- Map(%): map
- Verbatim string(=): used when printing text as-is
Set client name SETNAME
You can set a client name.
When you grant command permissions per user with ACL (Access Control List), it is safer to grant hello permission instead of granting the client command just to set a client name. The Client command can also kill other clients with the kill subcommand.
Syntax
HELLO [<protocol-version> [AUTH <user> <password>] [SETNAME <name>]]
- Available since version 6.0.0.
- Since version 6.2.0 you can use hello without specifying protocol-version.
- Time complexity is O(1).
| << AUTH | HELLO | ECHO >> |
|---|
