Reputation: 11
In redis cli, sometimes I want to get a random value, but to do this, I have to execute randomkey
, and copy the result as the parameter of get
, is there a pipe so I can execute randomkey | get
in one line to save me from copying?
Upvotes: 1
Views: 515
Reputation: 49942
The CLI itself doesn't have that, but the operating system - if it is *nix - offers xargs
for that:
~$ redis-cli FLUSHALL
OK
~$ redis-cli SET foo bar
OK
~$ redis-cli SET baz qaz
OK
~$ redis-cli RANDOMKEY | xargs redis-cli GET
"qaz"
~$ redis-cli RANDOMKEY | xargs redis-cli GET
"bar"
~$ redis-cli RANDOMKEY | xargs redis-cli GET
"qaz"
Upvotes: 1