Memcache and Smarty
Rob Sharp
rob.sharp at thesoundalliance.net
Mon Sep 10 13:35:58 UTC 2007
> On 10 Sep 2007, at 08:50, Rob Sharp wrote:
>
>
>
> > Smarty will compile each of these sections individually and then
> > cache the page as a whole. There's not currently (AFAIK)
> > template-level caching in Smarty, but one of my co-workers has a
> > working implementation that we're testing.
>
>
>
> That's not true. Smarty caches whole templates, but one template can
> be included in another, hence you can get selective caching of page
> elements. Read the docs carefully as it's quite
> fiddly: http://smarty.php.net/manual/en/caching.php
>
> In particular notice {insert}, and also that plugins can choose
> whether their output is cached.
>
>
>
Ah, I see what you mean. We use include in preference to fetch - for
variable scoping reasons - and that means we only have page-level
caching. Obviously using fetch has the caching advantage, but requires
explicit variable assignment over a global scope.
Back to memcache, this is a smarty example of the plugin we're using to
cache templates in memcache:
{cacheBlock cacheHashData=$digestItem timeout=60
include="comps/apps/digest/entry.tpl"}
'cachehashData' is both passed into the template, and used to uniquify
the key, and 'include' is the template to load
It's very simple, but solves a common problem for us. Ideally the TTL
would be abstracted from the templates, but this is a 10 minute fix
that's still under development. We've yet to benchmark, but the template
in question is incredibly data-intensive (it retrieves activity digest
data for a given user), so it works a treat for our situation.
Is anyone using something similar, or have a better approach to that
issue?
Regards,
Rob.
> 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/
>
>
>
>
>
>
Rob Sharp
Development Lead
telephone: 02 9282 4038
facsimile: 02 9282 4099
skype: qu4nnum
Sound Alliance
inthemix : FasterLouder : Thought By Them : SameSame
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070910/f98fc7f5/attachment.html
More information about the memcached
mailing list