Redis RANDOMKEY – How to get random key stored in redis

5 years ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get a random key currently stored in redis datastore by using a COMMAND – RANDOMKEY in redis-cli. The syntax of redis RANDOMKEY command is as follows :-

Syntax :-

redis host:post> RANDOMKEY

Output :-

- random key from datastore.
- nil, if datastore is empty.

Example :-

Redis RANDOMKEY

References :-

  1. RANDOMKEY Command Docs

That’s all for how to get a random key stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.