To understand how to manage keys , take the following steps:
- Open a Terminal and connect to Redis with redis-cli.
- To find out how many keys are in Redis, we will perform the following operation:
127.0.0.1:6379> DBSIZE (integer) 50000
- 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)
- 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" ...