Redis中固定大小的排序集? [英] Sorted set of a fixed size in Redis?

查看:68
本文介绍了Redis中固定大小的排序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Redis的菜鸟,最近在思考处理out系统高并发情况的解决方案时遇到了一个问题,我想用Redis,大家都知道从In-Memory访问是很好的比IO快.Redis sorted set是一个可能的工具,我们想要一个固定大小的sorted set来包含用户的手机号码,我谷歌/百度了很多,没有找到任何有意义的消息,所以谁能告诉我如何指定Redis Sorted 设置固定大小?并且 set 应该告诉我对有序 set 的任何添加操作是否成功?

I'm a rookie in using Redis, and recently have a problem when I'm thinking the solution to handle the case of high concurrency in out system, I want to use Redis, everybody know access from In-Memory is great faster than IO. Redis sorted set is the possible tool for use to do it, we want to a fixed size of sorted set to contain the user's mobile number, I Googled/Baidued a lot, didn't find any meaning message, so can anybody tell me How to specify Redis Sorted Set a fixed size? And set should tell me any add operation to sorted set is success or not?

谢谢

推荐答案

我认为您无法指定大小,您必须自己检查.

I don't think you can specify a size, that you will have to check it yourself.

您可以使用ZCARD

ZCARD KEY

或者你可以删除第一个元素 ZREMRANGEBYRANK

Or you could just remove the first element ZREMRANGEBYRANK

[ZREMRANGEBYRANK][2] [KEY] 0 -[YOURSIZE]

这篇关于Redis中固定大小的排序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆