如何确定某物是否是有序集的成员?
据我所知,没有任何命令可以实现此目的,但我需要类似于 SISMEMBER 命令的命令,但用于订购套。鉴于没有这方面的命令,确定某物是否是有序集的成员的最佳方法是什么?也许可以询问 ZCORE 会员的分数,如果没有分数就等于没有会员?
From what I see there's no command for this, but I need something similar to the SISMEMBER command, but for ordered sets. Given that there's no command for this, what's the best way to determine if something is a member of an ordered set ? Maybe ask for the score of the member with ZCORE and if there's no score than there's no member ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所建议的,我只会使用
ZSCORE
。如果返回 nil,则请求的成员不在集合中。ZRANK
也可以,但它的 O(log n) 和ZSCORE 是 O(1)。
As you suggested, I would just use
ZSCORE
. If nil is returned, then the requested member is not in the set.ZRANK
would also work, but it's O(log n) andZSCORE
is O(1).