get keys and values at command prompt

2020-05-11 21:29发布

I have a very small data saved in redis and the following is working as expected that will allow me to download all keys.

redis-cli keys * 

Is there any way to get the keys+values * ?

标签: redis
1条回答
Ridiculous、
2楼-- · 2020-05-11 22:01

There's no command for that, but you can write a script to do so.

You will need to perform for each key a "type" command:

> type <key>

and depending on the response perform:

  • for "string": get <key>
  • for "hash": hgetall <key>
  • for "list": lrange <key> 0 -1
  • for "set": smembers <key>
  • for "zset": zrange <key> 0 -1 withscores

Keep in mind that for hashes and sorted sets you will be getting the keys/scores and values.

查看更多
登录 后发表回答