Redis - Get keys using redis-cli

by
Jeremy Canfield |
Updated: April 15 2024
| Redis articles
If you don't have the Redis CLI installed, check out my article Install redis-cli from source.
This assumes you are able to connect to Redis using the redis-cli. If not, check out my article Connect to Redis using the redis-cli.
The keys * command can be used to display all of the keys in your redis cache.
~]$ redis-cli -h redis.example.com -p 6379
redis.example.com:6379> keys *
1) "foo"
2) "bar"
Or like this, using the --scan flag.
~]# redis-cli --scan
foo
bar
--scan and --pattern can be used to return keys that match the pattern.
~]$ redis-cli --scan --pattern '*POC*'
flask_cache_/POCbcd8b0c2eb1fce714eab6cef0d771acc
Or, to determine if a specific key exists.
redis.example.com:6379> keys foo
1) "foo"
redis.example.com:6379> keys bogus
(empty array)
get can be used to return the value of a string key.
my-redis-cluster.abc123.clustercfg.use1.cache.amazonaws.com:6379> get foo
"bar"
Did you find this article helpful?
If so, consider buying me a coffee over at