redis-cli: the Redis command line interface (redis-tools)
redis-cli [-h HOST] [-p PORT] [--tls] [-a PASSWORD] [-c] [COMMAND [ARG ...]]
Options you will use
-h HOST- server hostname (default 127.0.0.1): for ElastiCache the primary, reader or configuration endpoint
-p PORT- server port (default 6379)
--tls- connect over TLS - required when the replication group has in-transit encryption
-a PASSWORD- AUTH with this password (the ElastiCache AUTH token); prints a warning, use REDISCLI_AUTH instead
-c- cluster mode: follow -MOVED and -ASK redirections
--raw- raw replies (the default when the output is not a terminal)
Examples
$ redis-cli -h master.sessions.abc123.euc1.cache.amazonaws.com PINGis it up (PONG)
$ redis-cli -h HOST SET cart:1 apples EX 300a key that expires in 5 minutes
$ redis-cli -h HOST INFO replicationrole, connected replicas, offsets
$ redis-cli -c -h clustercfg.x.abc123.euc1.cache.amazonaws.com GET user:42cluster mode: follow redirections
Gotchas
- Without a COMMAND it is interactive: HOST:PORT> prompts until quit.
- In a terminal replies are typed: "value" (a string), (integer) 1, (nil), (error) ..., 1) "key" (an array). Piped, they are raw.
- ElastiCache: the reader endpoint balances over the replicas; writing there fails with READONLY. Cluster mode enabled spreads keys over 16384 hash slots: without -c a key in another shard answers MOVED <slot> <ip>:6379.
- ElastiCache is reachable only from inside its VPC (security group on 6379).
Try redis-cli in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.