#7338: Method .cache(timeout) in QuerySet
---------------------------------------------------+------------------------
Reporter: marinho | Owner: marinho
Status: assigned | Milestone:
Component: Database layer (models, ORM) | Version: SVN
Resolution: | Keywords:
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Comment (by msaelices):
I think Malcolmn is right. You cannot rely on a cache that you cannot
control for invalidation. But I think this patch maybe can be a good idea
to get a default cache system in Django ORM.
I will introduce what I think is the main problem with this patch:
invalidation.
It would be great that, for example, in a {{{FooModel}}} saving, you could
flush from cache all possible querysets from {{{FooModel}}}. Then it would
be fantastic if you can do something like:
{{{
#!python
FooModel.objects.delete()
}}}
But with this patch this cannot be possible, because it uses hash cache
key, and for memcached you cannot flush a bunch of keys (without hacking
things). Therefore, if you have several views that uses FooModel
querysets, like that:
{{{
#!python
# view 1
FooModel.objects.all()
# view 2
FooModel.objects.filter(published=True)
}}}
Every previous queryset has a diferent SQL sentence, and this means a
different hash and cache key. I think a valid approach to get
{{{Manager.invalidate}}} method could be something like:
1. For every {{{cache()}}} call, besides generate a hashed cache key, you
can add key value into a register cached in memcached also (but with a
larger timeout) that maintains all cached keys from this manager.
1. When {{{invalidate()}}} get called, this method will iterate into its
cached register and will flush all querysets.
¿what is your opinion about this?
--
Ticket URL: <http://code.djangoproject.com/ticket/7338#comment:13>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---