Memcaching Plan of Attack

Toby Corkindale tjc at
Fri Apr 11 01:07:22 BST 2008

On Thu, Apr 10, 2008 at 06:34:38PM +0100, Jason Tang wrote:
> After a diversion to get some ground work going on side project, I'm back on the
> memcached project. I'm pretty much a n00bie and interested wise words
> from those with er.. experience :) I'm interested to hear how you
> approach applying memcached to existing webapp.
> For example:
> I have a summary page listing order items that need packing. The schema is
> badly put together, but I've replaced the chunks of SQL with DBIC
> so at least we stand a chance in consolidating the data access. Sadly
> the packing items requires 3 queries to provide a summary showing
> everything needed.
> So add abit of code to check if it exists in memcached if not hit db,
> and save it into memcached. Now am I going to have to find all refernces
> to those tables adn get them to expire that memcached entry?

Memcached can expire things itself; it's a global setting, I think.

Then, put some hooks into the DBIC table classes so that upon update, they also
update memcached.

Try to cache entire chunks of data though, rather than just single rows.
So, for eg, if your listing item needs three SELECTs to build it, then in DBIC
you want to provide a ResultSet function that gets the whole thing - then put
the memcache logic into (or near) that function.

More information about the mailing list