skip to content
Alvin Lucillo

Retrieve values of all keys

/ 1 min read

You can just pass all keys to MGET to get their value. xargs just transforms the newline-separated keys into positional arguments for MGET

 redis-cli KEYS 'domain*'                         
1) "domain1:key2"
2) "domain2:key3"
3) "domain1:key1"
 redis-cli KEYS 'domain*' | xargs -r redis-cli MGET
1) "value2"
2) "value3"
3) "value1"