Redis RANDOMKEY command is used to get a random key from Redis database.
Return Value
String, a random key or nil, if the database is empty.
Syntax
Following is the basic syntax of Redis RANDOMKEY command.
redis 127.0.0.1:6379> RANDOMKEY
Example
First, create some keys in Redis and set some values in it.
redis 127.0.0.1:6379> SET Adglob1 redis OK redis 127.0.0.1:6379> SET Adglob2 mysql OK redis 127.0.0.1:6379> SET Adglob3 mongodb OK
Now, get a random key from Redis.
redis 127.0.0.1:6379> RANDOMKEY 1) Adglob3
Pingback: Redis - Keys - Adglob Infosystem Pvt Ltd