[development] Object caching (was: memcache)

AjK andy at pingv.com
Wed Mar 7 17:25:31 UTC 2007



> If you're talking about object caching where in 90% of the cases the
> objects live in the database, I wonder whether this kind of caching
> would have a better payoff than just increasing the memory caching done
> by the DB engine (mysql,etc). It doesn't strike me as a big payoff for
> the code that it would take too achieve.

90% may well live in the database but in a disparate way. Nodes are
"constructed". If you have say 10 modules all adding their own unique
goodness to the $node object via hook_load() or hook_nodeapi() then there's
a lot of database queries going on during that construction process. Add to
that the PHP overhead of calling all those hooks during the construction
phase then the db layer caching starts to become minor even though still
beneficial.

If you can cache the resulting constructed object into a memcache (or file,
whatever) you save yourself all that construction overhead. You can just
quickly recover the ready assembled object from cache. Expiring the cache
can be done in node_save() and the next node_load() reconstructs/caches the
node again. Same for user and comment objects. Cache expiry when adding a
new module (or removing one) would be needed also.

But getting a cache set-up like this can have great benefits. I think that's
what this thread is about, isn't it?

--Andy



More information about the development mailing list