Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

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.


Preconditions

Usage Examples

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

Info

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.

1) INFO keyspace

For a quick overview of the number of keys and their average TTL:

Code Block
languagebash
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.

2) List all keys with no TTL

List all keys with no TTL in redis instance redis in redis database DBNUMBER $DBNUMBER in redis instance REDISHOST $REDISHOST:

Code Block
languagebash
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

3) Redis trouble shooting

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 db1you need to run SELECT

Code Block
> select db1

before any other command. For list of all redis-cli commands, you can visit https://redis.io/commands/


Related tutorials

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel in ( "redis" , "database" , "cache" ) and space = currentSpace ( ) and ancestor = "2014352487"

Related components

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel in ( "redis" , "database" , "cache" ) and space = currentSpace ( ) and ancestor = "2014350220"

Status
colourYellow
titleintermediate

Table of Contents
exclude(Related * | Recommended * |Table of contents).*


Filter by label (Content by label)
showLabelsfalse
max10
showSpacefalse
sorttitle
titleRelated questions
cqllabel in ( "redis" , "database" , "cache" ) and ancestor = "2014351598" and space = currentSpace ( )