Memcache and Smarty

Marcus Bointon marcus at
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 

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 Bointon
Synchromedia Limited: Creators of
UK resellers of info at hand CRM solutions
marcus at |

More information about the memcached mailing list