Notes:
- In the example below I am using
redis-cli
and regular strings to simply explain logic. In the app itself the RESP protocol is being used for communication - Redis command names are case-insensitive, so ECHO, echo and EcHo are all valid commands.
PING
- for checking health. Supposed to return "PONG" as response
$ redis-cli PING
PONG
ECHO
- returns same message that was sent
$ redis-cli echo message
message
- Note: if echo receives more than one word it will return an error
$ redis-cli echo some message
Wrong number of arguments for 'ECHO' command
SET
- command used to set a key to a value. Can accept px argument which is a keyword for expiry. The value is passed of expire is passed in milliseconds
$ redis-cli set foo bar
Or set expiration to be 100 milliseconds
$ redis-cli set foo bar px 100
GET
- command used for getting a value with key. Returns null bulk string in case if it's not set or expired
$ redis-cli set foo bar
$ redis-cli get foo
bar