How to delete template fragment cache?

175 views
Skip to first unread message

Bartek SQ9MEV

unread,
Dec 3, 2008, 2:37:41 AM12/3/08
to Django Users
Hi all, I'm quite newbie in Django.
I use template fragment caching ({% cache ...%}...{% endcache %}. This
fragment changes rather seldom, changes originate only from admin site,
są for me its obvious to delete cache at adding objects from admin, and
use quite large tiemeout for my caches.

How can I delete cache for particular fragments at saving objects?

I know I should use cache.delete('a'), but how can I get key for
particular fragment?

What is better idea? Use signals (I do not know too mouch about them
yet)or just overwrite model_save method?

I use memcached backend.
--
Pozdrawiam
Bartek
jid: bar...@sq9mev.info

Nathaniel Whiteinge

unread,
Dec 3, 2008, 2:32:36 PM12/3/08
to Django users
On Dec 3, 12:37 am, Bartek SQ9MEV <bar...@sq9mev.info> wrote:
> I know I should use cache.delete('a'), but how can I get key for
> particular fragment?

The key is 'fragment_name:additional:arguments:seperated:by:colons'.

> What is better idea? Use signals (I do not know too mouch about them
> yet)or just overwrite model_save method?

It doesn't really matter. Signals are most useful, IMO, for tying
behavior to events that happen in apps you don't control (3rd-party,
contrib, etc.).
Reply all
Reply to author
Forward
0 new messages