Bercovici Adrian
Bercovici Adrian

Reputation: 9360

How to see what Redis-Commands RESP representation

Hello is there a way to find out the string representation of Redis commands , following the RESP protocol?

For example i am trying to get all the keys from the database using the Keys * command. However i do not know if this command is a simple string or a Bulk string or an Array of Bulk Strings:

Simple String representation: +Keys *\r\n
Bulk String representation: $6\r\nKeys *\r\n
Array of Bulk String representation : *1\r\n$6\r\nKeys *\r\n

Is there any way to see the bytes/string that the Redis-server knows how to respond to?
Is there any lookup table ?

For Keys command according to the REDIS documentation it is not stated how the request message should be constructed :

Returns all keys matching pattern.

While the time complexity for this operation is O(N), the constant times are fairly low. For example, Redis running on an entry level laptop can scan a 1 million key database in 40 milliseconds.

Examples
redis> MSET firstname Jack lastname Stuntman age 35
"OK"
redis> KEYS *name*
1) "lastname"
2) "firstname"
redis> KEYS a??
1) "age"
redis> KEYS *
1) "lastname"
2) "firstname"
3) "age"
redis> 

Upvotes: 0

Views: 789

Answers (1)

Sripathi Krishnan
Sripathi Krishnan

Reputation: 31528

Use telnet to connect to the redis server and type your command. You will see the output without any post processing.

Upvotes: 3

Related Questions