How to show ALL keys through redis-cli?

I would say there are two possibilities:

1/ The django app may not connect to the Redis instance you think it is connected to, or the redis-cli client you launch does not connect to the same Redis instance.

Please note you do not use the same exact connection mechanism in both cases. Django uses a Unix Domain Socket, while redis-cli uses TCP loopback (by default). You may want to launch redis-cli using the same socket path, to be sure:

$ redis-cli -s /tmp/redis_6379.sock

Now since you have verified with a MONITOR command that you see the commands sent by Django, we can assume you are connected to the right instance.

2/ There is a database concept in Redis. By default, you have 16 distinct databases, and the current default database is 0. The SELECT command can be used to switch a session to another database. There is one keyspace per database.

The INFO KEYSPACE command can be used to check whether some keys are defined in several databases.

redis 127.0.0.1:6379[1]> info keyspace
# Keyspace
db0:keys=1,expires=0
db1:keys=1,expires=0

Here I have two databases, let's check the keys defined in the db0 database:

redis 127.0.0.1:6379> keys *
1) "foo"

and now in the db1 database:

redis 127.0.0.1:6379> select 1
OK
redis 127.0.0.1:6379[1]> keys *
1) "bar"

My suggestion would be also to check whether the Django application sends any SELECT command at connection time to the Redis instance (with MONITOR).

I'm not familiar with Django, but the way you have defined the LOCATION parameter makes me think your data could be in database 1 (due to the suffix).


Do this:

redis-cli -h <host> KEYS "trendingKey*"

OUTPUT

  1. "trendingKey:2:1"
  2. "trendingKey:trending102:1"
  3. "trendingKey:trending101:1"

Tags:

Django

Redis