Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass results to another command in redis

Is there a way to pass the return value of one function to another in Redis? Of course, if you're using a language wrapper (like Ruby), it's easy — but what about from the CLI?

e.g. something like this, bash style

redis 127.0.0.1:6379> keys student* | mget

or something like this

redis 127.0.0.1:6379> mget(keys student*)

keys student* will return a list of keys, but I've no idea how to fetch all the values for those keys.

Thoughts?

like image 849
tekknolagi Avatar asked Sep 07 '12 07:09

tekknolagi


1 Answers

From the CLI, you just have to let the shell do its job.

./redis-cli --raw keys 'student:*' | awk '{printf "get %s\n", $1}' | ./redis-cli --raw

Please note you are not supposed to use the keys command in applications because of its linear complexity.

like image 158
Didier Spezia Avatar answered Oct 05 '22 07:10

Didier Spezia