List of useful Redis commands

Shortcuts

Redis clients

There are multiple Redis clients. The best command line is the official Redis client, called Redis CLI. To install it on Debian based distros:

$ sudo apt install redis-tools

Connecting to a Redis cluster

$ redis-cli -u redis://[USERNAME]:[PASSWORD]@[HOST]:[PORT]

Example:

$ redis-cli -u redis://default:password@redis-10123.crce986.ca-central-1-1.ec2.redns.redis-cloud.com:17285

List all the keys

127.0.0.1:6379> KEYS *

Delete a key

127.0.0.1:6379> DEL [key_name]

Show a hash field

127.0.0.1:6379> HGET [hash]  [field]

Show the entire content of a hash

127.0.0.1:6379> HGETALL [hash]

Remove a field from a hash

127.0.0.1:6379> HDEL [hash] [field] [field ...]

Delete all the hashes (keys)

127.0.0.1:6379> FLUSHALL

Show a TTL for a hash

127.0.0.1:6379> TTL [hash]