Redis Keys: RANDOMKEY
Redis RANDOMKEY Command
Redis RANDOMKEY command is used to get a random key from currently selected redis database.
Here are some common uses and scenarios for the "RANDOMKEY" command:
- Sampling: Select random keys for statistical analysis or sampling purposes.
- Load Testing: Randomly access keys to simulate load on the Redis instance.
- Monitoring: Inspect random keys to check for unexpected or outlier data.
- Debugging: Retrieve random keys for troubleshooting or debugging purposes.
Syntax:
RANDOMKEY
Available since
1.0.0.
Return Value
Bulk String reply:
a random key or nil, if a database is empty.
Return Value Type
String
Example: Redis RANDOMKEY
First, create some keys in redis and set some values in it.
127.0.0.1:6379[1]> RANDOMKEY "KEY" 127.0.0.1:6379[1]> RANDOMKEY "key1"
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/redis/redis-randomkey.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics