0

I ran into something odd today. I found that using $ redis-cli FLUSHDB, I can remove a database and its contents just fine. When I use $ redis-cli FLUSHALL however, it leaves a database which can be seen with $ redis-cli INFO KEYSPACE, but which has no visible keys from $ redis-cli KEYS *. Using $ redis-cli SELECT 0 didn't seem to restore this either. What's going on?

/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
/redis_data $ redis-cli KEYS *
(empty array)
/redis_data $ ##### just added 10 values from a separate container #####
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
db0:keys=10,expires=0,avg_ttl=0
/redis_data $ redis-cli KEYS *
 1) "2022-09-29T16:17:46.519Z_log"
 2) "2022-09-29T16:17:47.020Z_log"
 3) "2022-09-29T16:17:48.023Z_log"
 4) "2022-09-29T16:17:45.015Z_log"
 5) "2022-09-29T16:17:47.522Z_log"
 6) "2022-09-29T16:17:49.024Z_log"
 7) "2022-09-29T16:17:46.018Z_log"
 8) "2022-09-29T16:17:48.524Z_log"
 9) "2022-09-29T16:17:45.517Z_log"
10) "2022-09-29T16:17:44.519Z_log"
/redis_data $ redis-cli FLUSHDB
OK
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
/redis_data $ redis-cli KEYS *
(empty array)
/redis_data $ ##### add 10 values again #####
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
db0:keys=10,expires=0,avg_ttl=0
/redis_data $ redis-cli KEYS *
 1) "2022-09-29T16:20:53.203Z_log"
 2) "2022-09-29T16:20:55.709Z_log"
 3) "2022-09-29T16:20:54.707Z_log"
 4) "2022-09-29T16:20:52.702Z_log"
 5) "2022-09-29T16:20:55.206Z_log"
 6) "2022-09-29T16:20:56.710Z_log"
 7) "2022-09-29T16:20:52.206Z_log"
 8) "2022-09-29T16:20:56.210Z_log"
 9) "2022-09-29T16:20:54.205Z_log"
10) "2022-09-29T16:20:53.703Z_log"
/redis_data $ ##### Per the above, FLUSHDB works fine. Let's try FLUSHALL #####
/redis_data $ redis-cli FLUSHALL
OK
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
/redis_data $ redis-cli KEYS *
(empty array)
/redis_data $ ##### add 10 values again #####
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
db0:keys=10,expires=0,avg_ttl=0
/redis_data $ redis-cli KEYS * ##### this should give the 10 keys, but it doesn't #####
(empty array)
/redis_data $ redis-cli SELECT 0
OK
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
db0:keys=10,expires=0,avg_ttl=0
/redis_data $ redis-cli KEYS * ##### SELECT 0 didn't help either #####
(empty array)
/redis_data $ ##### add 10 values again to test if it's writeable #####
/redis_data $ redis-cli INFO KEYSPACE
# Keyspace
db0:keys=20,expires=0,avg_ttl=0
/redis_data $ redis-cli KEYS * ##### we can see keys increased to 20, so it's still writeable, just KEYS isn't finding it #####
(empty array)
Drake
  • 63
  • 8
  • What exactly are you expecting from FLUSHALL? – sazzad Sep 29 '22 at 17:43
  • @sazzad I was expecting FLUSHALL to work like FLUSHDB but for all databases instead of just one. In this situation, I was expecting them to work the same. – Drake Oct 03 '22 at 19:17

0 Answers0