My app will have multiple users logged in accessing their Twitter
accounts simultaneously. I'm using Hayes Davis' Grackle gem (http://
github.com/hayesdavis/grackle/tree/master) because I like that it's
very thin wrapper atop the API - really more a set of convenience
methods. I typically call methods on it directly in my controllers,
rather than pass calls to retrieve (for example) a user's friends list
through a User model of some sort.

Lately I've been trying to figure out the best way to handle caching.
I've realized that I need to cache some endpoints for individual users
(because Twitter responds differently based on the authenticated
user), while caching others endpoints once for all users (such as the
public timeline), and caching different endpoints for varying amounts
of time. I'm having a heck of a time figuring out at which level to
locate my caching code. I'm sort of leaning toward creating wrapper
objects that directly call Grackle, and calling those wrappers from
the controllers, so that the wrappers can employ the caching strategy.

I'm curious to hear how others implemented their caching.


-Bill

Reply via email to