Using MemCachier for Social Data
In-memory caches, like MemCachier, are great for speeding up access to popular or expensive database queries. But they can also help if your app uses an external data-source like the Facebook Developer API. Unfortunately, such APIs are often too high latency to service dynamic social applications alone. For example, I built a simple Facebook application that relies on caching to provide real-time search of users’ social graph. You can check it out here, or grab the code from GitHub here.
The example app allows users to figure out which Facebook friends are currently in a particular city by searching for that city. I wanted the search field to auto-complete city names as the user is typing, and I wanted to results to show up instantly. Unfortunately, the Facebook API is pretty high latency - good enough for the occasional query, but not as good for real-time. So, I couldn’t just forward the user’s query to Facebook every time they type in a letter.
By grabbing all of the users’ friends on login and sticking them in the cache, my demo app could process searches without having to talk to Facebook at all!