我正在评估类似于Tinder的位置基础约会应用程序的后端.
经过研究,我很困惑是否有一个共同的"最佳实践"数据模型,为此算法.我的方法是使用Redis Cluster:
// Store all online users in same location (city) to a Set. In this case, store user:1 to New York set
SADD location:NewYork 1
// Store all users age to Sorted Set. In this case, user:1 has age 30
ZADD age 30 "1"
// Retrieve users in NewYork age from 20 to 40
ZINTERSTORE tmpkey 2 location:NewYork age AGGREGATE MAX
ZRANGEBYSCORE tmpkey 20 40
Run Code Online (Sandbox Code Playgroud)
我没有经验,如果数百万并发用户发生扩展,我无法预见潜在的问题.
希望任何退伍军人都能解释一下.