Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID


edited May 2012 in Documentation

Jbroadway, how do you suggest caching handler output on a per user basis?

My app generates a different list of items for each individual user (pulled out of a general over all list of items). How would I go about caching that specific users list so I only need to update it once they themselves update the status of an item which would simply update their cache. I am trying to avoid overloading my database dynamically rebuilding their list every time they hit that page. I know how I used to do this, but I am wondering how to do it within the framework.

Build with some sort of scalability in mind now, so it won't be as large of an issue if it comes up later.


  • Can you just add their user ID to the cache key? For example:

    $memcache->cache (
        sprintf ('my_cache_key_%d', User::val ('id')),
        function () {
            return array ('cache' => 'this', 'stuff' => 'please');
  • That should do it. Now to figure out how to string lots of these together and figure out when to smash them. Hmmm.

    Or maybe I should just worry about this after I have enough people using the app it actually starts slowing down... that might be an even better solution.

Sign In or Register to comment.