redis - 新浪微博里的共同好友的查找是如何实现的
伊谢尔伦
伊谢尔伦 2017-04-21 11:16:41
0
3
1322

今天看了一个老视频:http://v.youku.com/v_show/id_XMzM3NjgzMjY4.html
里面说到这个问题“A关注了B,B也关注A,要得到两个人的共同好友,好友取交集。如果A是一个粉丝有3000万的大V,而B是粉丝只有1000的屌丝,要找出他们的共同好友,应该怎么做?”
视频看完了,我却米有找到答案。大家帮忙分析下。

首先得是redis,第二,得合理,不能用户查看的时候等待个四五秒。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
大家讲道理

This calculation process is not a one-time http operation, and it cannot be calculated immediately unless you are a very experienced algorithm engineer and data engineer.
These things are calculated slowly in the background. Otherwise, what do the data mining engineers rely on? When the calculated results are calculated, they will start pushing them to you. At this time, the benefits of using static language and resident memory on the server side can be reflected.

伊谢尔伦

After watching the video, it was clearly stated: pre-calculation. (Watch from 10 minutes and 30 seconds)
Just calculate it when you pay attention (inserting data).

巴扎黑

It’s easy to use redis sets.
Example:
user:1:fans [2,3,4] //Follow users 1
user:1:follows [2,5,7,8] //User 1 follows

user:2:fans [1,3,4] //Follow users 2
user:2:follows [1,7,8] //User 2 follows

When user 1 logs in, he can get the friend relationship by taking the intersection of user:1:fans and user:1:follow. Then, can he get the intersection by taking the intersection of user:1:follows and user:2:follows? Users you follow in common? I believe I don’t need to explain the rest of the intersection differences, you should know it too

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template