This may be exceedingly obvious, but it took me a little bit of
Googling for "template fragment caching expiry" before I realized
there was an easier way to do what I was looking for.
I use template fragment caching (so simple!), but it's annoying when
someone comments and his comments don't show up for several minutes.
In order to create a new cached block when a new comment is received,
one simply needs to put the comment_count into the cache tag's list of
arguments.
- E.g. -
{% get_free_comment_count for blog.entry object.id as comment_count %}
{% cache 300 entry_comments object.id user.is_authenticated
comment_count %}
The two downsides that I see are:
* the need to hit the database to get the comment count
* the creation of a new cache object while retaining the old one
If you are receiving hundreds of comments a minute, this system would
quickly balloon out of control, but it's a nice, simple solution for a
personal site.
Does anyone have a better way to do this, excluding using the low-
level cache API?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---