This FAQ shows how you can use redis-cli. |
Redis is a key-value store. The keys and their values are stored in separate databases, which are numbered db0, db1, …
You can use the redis-cli (command line interface) to interact with the Redis API to control records stored at our component Redis (AWS ElastiCache). We provide the redis-cli on your bastion host.
Activated redis-cli
on the bastion host. Contact our service team at service@root360.de or create a ticket at https://support.root360.cloud to activate the redis-cli
tool on your bastion host
Access to the bastion host via SSH (see Access an environment via OpenSSH or Putty ).
You can connect to your Redis via the redis-cli with the following command to run on the bastion host: redis-cli -n 1 -h $redishost
As a common use case you may use the redis-cli tool to identify objects which does not provide a Time-To-Live (TTL). Such objects are not deleted according to their defined TTL and may increase memory utilization at a critical level. |
For a quick overview of the number of keys and their average TTL:
redis-cli -h redis info keyspace # Keyspace db0:keys=2414,expires=2409,avg_ttl=734255 db1:keys=7177856,expires=0,avg_ttl=0 db2:keys=305579,expires=305579,avg_ttl=37469529 |
expires
is the number of keys with an expiration/ttl configured for that database. avg_ttl
is the average ttl for keys in that database. Only keys that have a ttl are included in the calculation.
List all keys with no TTL in redis instance redis
in redis database DBNUMBER
in redis instance REDISHOST
:
redis-cli -n DBNUMBER -h REDISHOST --scan | while read LINE ; do TTL=`redis-cli -h REDISHOST ttl "$LINE"`; if [ $TTL -eq -1 ]; then echo "$LINE"; fi; done; |
To run this command you need to replace placeholder DBNUMBER
and REDISHOST
with information of your environment
If you use redis-cli
to troubleshoot redis. Redis will automatically select db0
. Select the Redis logical database having the specified zero-based numeric index.
Eg. to work at db1
you need to run
> select db1 |
before any other command. For list of all redis-cli commands, you can visit https://redis.io/commands/
INTERMEDIATE