Search code examples
phpmysqlcachingsocial-networking

how to retrieve custom user search results for a social networking site


I have a social networking site written in PHP and using a MySQL db. I currently show a preview of users online on the front page for people who aren't logged in. This can be easily cached as the results are the same for everyone.

My problem is that logged in users can block each other, and to deliver custom search results that makes it very difficult to cache (I am using APC for other easily cacheable things.) I have thought about caching one common resultset (males searching for females for example) and then keeping a list of that members blocked users in memory and removing the undesired members from the search - but this makes pagination calculation painful and seems inefficient.

At the start this was no problem, but now with 100k+ members and some very active users it is becoming a big issue!

I feel like there is a more efficient way of doing this and I am looking for ideas :D


Solution

  • You can replace nickname of the 'blocked' user by some placeholder ('blocked', or 'undesired') when registered user are looking at the list.
    See, how SO does same thing with 'Ignored Tags' (on main page) - questions with ignored tags just becomes faded.
    It will allow you to skip pagination issues.