How to do it...

To understand how to manage keys , take the following steps:

  1. Open a Terminal and connect to Redis with redis-cli.
  2. To find out how many keys are in Redis, we will perform the following operation:
127.0.0.1:6379> DBSIZE 
(integer) 50000
  1. If you are eager to know the keys in the Redis Server, two types of API can be used. The first one is KEYS:
127.0.0.1:6379> KEYS * 
    1) "detailed_registration:8001" 
    2) "company:3859" 
    3) "user_agent:4820" 
4) "detailed_registration:9330" 
... 
50000) "company:2947" 
(9.30s) 
 
  1. Another one is SCAN:
127.0.0.1:6379> scan 0 1) "20480" 2) 1) "detailed_registration:8001" 2) "company:3859" 3) "company:3141" 4) "detailed_registration:9657" 5) "user_agent:2325" 6) "company:1545" 7) "company:2521" 8) "detailed_registration:1253" ...

Get Redis 4.x Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.