the current data table is designed like this
suppose that the table name is user_fans user A user id is 1 user B user id is 2
user A follows user B and inserts data, the four fields are respectively 1 120
user B follows user An and the data is inserted, the four fields are 22 10
then they are mutual fans. I changed the status fields of the two records from 0 to 1
user A views his fan list SQL is select fans_id, status from user_fans where user_id = 1
then the status field can be used to determine the status of the relationship between user A"s fans and user A
but there is a problem, for example, when user A looks at user B"s fan list
, the relationship between user B"s fan list and user An is not clear.
can only query all the user id followed by user A first, and then traverse user B"s fan list (suppose 20 people are checked out. Traversing the 20-length array)
in the foreach loop to determine whether the id of user B"s fans is in the array followed by user A
if the amount of data is small, there should be no performance problem
but for example, if user A follows 3000 people, then there will be 3000 ID,
in the user array followed by user A, so that user A will be slow to check other people"s fan list every time, causing performance problems. Is there a good way to solve this problem?
see some articles on the Internet saying that fans and followers of such systems should use redis,. If how to use redis, what data type should be used?