gpt4 book ai didi

hash - 如何在 Redis Hash 上执行搜索?

转载 作者:行者123 更新时间:2023-12-03 06:41:13 29 4
gpt4 key购买 nike

我的游戏中有很多哈希值,例如

HMSET('hash1', 'level', 25, 'connected', 2)
HMSET('hash2', 'level', 50, 'connected', 2)
HMSET('hash3', 'level', 15, 'connected', 3)
HMSET('hash3', 'level', 15, 'connected', 2)

我想找到级别值为 50 的哈希。
我可以通过这个找到哈希吗,如果是,那么如何?

还指定 2 个查询,例如 level 为 15 并且 connected 必须小于 3?

最佳答案

Redis 不支持开箱即用的二级索引。但是,您可以使用不同的内置数据结构(如排序集)对其进行建模,您可以在此处阅读更多信息:https://redis.io/topics/indexes

如果您想要更高级的解决方案,您应该查看 RediSearch , RediSearch 是一个添加二级索引和全文和引擎的 Redis 模块。

关于hash - 如何在 Redis Hash 上执行搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61661702/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com