Redis stores keys and values in memory.
Sometimes we want to find the numbers of keys in Redis.
how to print the count number of keys
There are multiple ways to get keys counted in Redis First way,
127.0.0.1:6379> keys * 1) "roles"
127.0.0.1:6379> dbsize (integer) 1
127.0.0.1:6379> info keyspace # Keyspace db0:keys=1,expires=0,avg_ttl=0 db2:keys=1,expires=0,avg_ttl=0
Command To get all available keys
One way is using the
Key * command
Another way is using the scan command redis-cli –scan –pattern ‘*’