Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Memory 如何优化redis中sortedset的内存使用_Memory_Redis - Fatal编程技术网

Memory 如何优化redis中sortedset的内存使用

Memory 如何优化redis中sortedset的内存使用,memory,redis,Memory,Redis,使用sortedset存储用户事件: zrangebyscore Fred -inf +inf withscores 1) "SEQNO20180607001" [event's unique id] 2) "1514736000000" [event's time, a unix timestamp] 3) "SEQNO20180607002" 4) "1514736000230" 5) "SEQNO20180607003" 6) "15147360002235" 和一个简单的键值对来

使用sortedset存储用户事件:

zrangebyscore Fred -inf +inf withscores
1) "SEQNO20180607001"  [event's unique id]
2) "1514736000000"   [event's time, a unix timestamp]
3) "SEQNO20180607002"
4) "1514736000230"
5) "SEQNO20180607003"
6) "15147360002235"
和一个简单的键值对来存储事件的详细信息:

get SEQNO20180607001
"{\"name\":\"Fred\",\"age\":25,\"action\":\"click main page\"}"

比如,事件细节,它的值长度是不可预测的,所以我认为“哈希”不是一个好的选择,我在考虑sortedset的内存使用情况。有没有一个好的方法来最小化sortedset的内存使用情况?谢谢。

您真的需要存储时间放大器吗?你能用simpe列表和push事件来代替吗?如果需要,在json值中添加时间戳每个用户一个事件列表,您将只在一个位置获取数据我需要非常快速地获取特定时间范围内的用户事件(如“选择…其中user=Fred,时间介于xxx和yyy之间”),因此我想我必须存储时间戳