Memcache and Smarty

Marcus Bointon marcus at synchromedia.co.uk
Mon Sep 10 08:01:46 UTC 2007


On 10 Sep 2007, at 08:14, K J wrote:

> So you're basically saying, cache the output right before sending it
> to Smarty, and not cache the end html result.  Is that right?

Not really. The idea is that you cache the results of the MySQL  
queries, i.e. all the values that you've pulled from your DB that you  
pass to smarty with assign(). Smarty has it's own cache for static  
output, but it's not much use for dynamic content, though you can  
cache elements smaller than whole pages that don't need to change. If  
you're on a single server, don't bother with memcache, use APC  
instead as smarty sits perfectly in its performance sweet spot  
(caching of compiled template bytecode) and you'll get much better  
performance. You can use APC for caching values explicitly, just like  
you do with memcache - see http://www.php.net/manual/en/function.apc- 
store.php.

As Rob said, MySQL's query cache is ok, but it gets invalidated  
rather too easily so it's often not very efficient (unless your  
read:write ratio is very high). It's also slower to access a cached  
mysql query than it is to get the results of the same (earlier) query  
from memcached or APC.

Marcus
-- 
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
UK resellers of info at hand CRM solutions
marcus at synchromedia.co.uk | http://www.synchromedia.co.uk/




More information about the memcached mailing list