This week I needed to query an ElastiCache instance on AWS - which is Amazons version of Redis. I could not find a decent free client to query this remote dictionary, so I ended up using redis-cli on Ubuntu. Turns out: Redis is a wonderful and powerful system to work with.
Installation of redis-cli
You can install the Redis CLI on Debian based systems (Ubuntu) like with the APT package tool. We'll update and upgrade our packages, so we know we have the latest version:
sudo apt-get -y update; \
sudo apt-get -y upgrade; \
sudo apt-get -y install redis-tools; \
redis-cli --versionNote: this will install the Redis tools, not the Redis server.
Connect to your ElastiCache
You can now connect to your ElastiCache using the -h option. You can use -a to specify a password.
redis-cli -h my.url.to.redis.cache.amazonaws.comIf you run on a different port, you can specify that port with the -p option or specify the entire url with -u like this:
redis-cli -u redis://my.url.to.redis.cache.amazonaws.com:1234Useful queries
Here are some ways of querying your Redis instance:
# list all keys spaces
echo INFO keyspace | redis-cli -h my.url.to.redis.cache.amazonaws.com
# list all keys inside the Redis instance
redis-cli -h my.url.to.redis.cache.amazonaws.com --scan
# list all keys inside a Redis DB2
redis-cli -h my.url.to.redis.cache.amazonaws.com -n 2 --scan
# lists the keys that are big
redis-cli -h my.url.to.redis.cache.amazonaws.com --bigkeys
# counts the number of keys:
echo DBSIZE | redis-cli -h my.url.to.redis.cache.amazonaws.comThe INFO command has some nice features.
Further reading
This might also interest you: