Possibly related to – Redis command to get all available keys?
I have a Redis server storing SixPack data (https://github.com/sixpack/sixpack – a framework to enable A/B testing). I can monitor the Redis server and see the following sample entries when I run monitor command:
$ redis-cli monitor|grep 'TEST'
I can see that there are several keys being used/set. I am attaching a sample below:
1581720438.878978 [15 127.0.0.1:39722] "GETBIT" "sixpack:e:-28591_:excluded" "2307"
1581720439.623866 [15 127.0.0.1:39722] "LRANGE" "sixpack:e:-28003_:alternatives" "0" "-1"
1581720439.624209 [15 127.0.0.1:39722] "HGET" "sixpack:e:-28003_" "traffic_fraction"
1581720439.624557 [15 127.0.0.1:39722] "GET" "sixpack:e:-28003_:winner"
1581720439.624822 [15 127.0.0.1:39722] "HEXISTS" "sixpack:e:-28003_" "archived"
1581720439.625110 [15 127.0.0.1:39722] "EVALSHA" "bcbf3b3ac336a33c2cd7ad0e1fca28db7b49fdee" "1" "sixpack:e:-28003_Recapture:users" "ac945bf7-285e-4f69-83fd-1336e084a318"
However, when I try to access the keys by running $ redis-cli KEYS '*'
command, I only get an empty list (empty list or set)
.
Updated: I checked that this is not a cluster setup. I also check the DBSIZE command. It returns 0.
How can I derive the keys from the MONITOR output? Is there a way to get all the keys in a Redis CLI?
2
Answers
Based on the hint from @AlisterBulman, I ran the INFO command like this.
From the output I can see that the DB number '15' has the keys.
Then I ran this command to get the keys.
The appropriate database index should be used when running the KEYS command if more than one Redis database is in use.
Redis comes with 16 default ‘databases’ which can be used to split the keys up. To use them from the tool,
redis-cli -n 2
to start using the 3rd DB (the default is 0). Once inside the tool, or from the API, there is theSELECT 2
command (again, to select the db to use). More can be allowed for – it’s just a number in the redis.conf file.The Sixpack A/B testing tool configuration has two methods to be able to choose which Redis database to use – in the configuration is the key (eg)
redis_db: 15
, or it, and more can be set by environment variable:SIXPACK_CONFIG_REDIS_DB
, along with _PORT, _HOST, _PASSWORD & _PREFIX.