ericuni
ericuni

Reputation: 11

Is there the concept of pipe in redis cli?

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

Answers (1)

Itamar Haber
Itamar Haber

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

Related Questions