用于实时分析的 Redis 结构
我使用 Redis 作为实时分析应用程序的数据存储。
假设客户端每 20 秒 ping 一次服务器以表明它还活着。
在 Redis 中对此进行建模最有效的方法是什么?
每个客户端都有一个 clientid,每个访问者都有一个 uid。
我想过这样处理:
clientid_realtime 是关键,它包含一个哈希值,它是每个 ping 的 uid:timestamps,但这需要我获取所有哈希值并对它们进行排序。
此外,每个哈希键都会随着时间的推移而疯狂增长并变得非常大。
I'm using Redis as the datastore for a real-time analytics app.
Suppose that a client pings the server every 20 seconds to indicate that it's alive.
What's the most efficient way to model this in Redis?
Each client has a clientid and each visitor has a uid.
I've thought of approaching this like:
clientid_realtime is the key and it contains a hash which are the uid:timestamps of each ping, but this would require that I get all the hashes and sort them.
Also, each hash key would grow wildly over time and become very large..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果排序是首要要求,您应该使用排序集。要增加分数,您只需使用命令 zincrby 并将值设置为 1
If sorting is a top requirement you should use sorted sets. to increment the scores you only need to use the command zincrby with a value of 1