简体   繁体   English

Redis-获取所有以以下内容开头的密钥

[英]Redis - Get all Keys begining with

I'm using TinyRedisClient with PHP for making calls to my redis database. 我将TinyRedisClient与PHP一起使用,以对我的redis数据库进行调用。

I'm looking to GET all keys that being with Player: 我期待GET与被所有按键Player:

There are multiple keys such as Player:17364633 Player:12435435 How would I get these by only knowing they begin with Player: ? 有多个键,例如Player:17364633 Player:12435435仅知道它们以Player:开头,我如何才能得到它们?

Thanks 谢谢

You can use the KEYS command to fetch a list of keys, and then GET each of them: 您可以使用KEYS命令来获取密钥列表,然后GET每个密钥:

redis> KEYS Player:*
1) "Player:17364633"
2) "Player:12435435"
redis> GET Player:17364633
...

You can even do a little bit better by using MGET to fetch all the values at once. 通过使用MGET一次获取所有值,您甚至可以做得更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM