On 4 окт, 22:16, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Thu, 2007-10-04 at 12:11 -0700, Alexander Solovyov wrote:
> > Hi,
>
> > I'm working on some big site and we are using content types very often
> > (for generic relations). And there are one idea appeared - why not
> > cache content types in the memory completely.
>
> > Just replacing default manager of ContentType class (with monkey-
> > patching) with another, which will cache retrieved objects will remove
> > this query to database completely.
>
> > So I'm wondering - maybe someone already have done something like
> > this? Or maybe someone have thoughts?
>
> We are already doing that (caching them in memory) and for exactly the
> use-case you have discovered: generic relations are otherwise very
> costly.

Yeah, but there is no way to avoid them in many cases (tags, ratings,
reviews for
various types of objects). We already have helpers for speeding up
them and I think
we will release them to public after cleanup (and running site ;))

> Have a look at CONTENT_TYPE_CACHE in
> django/contrib/contenttypes/models.py.

Thanks, I've seen that earlier, but forgot about it. But this is
unusable for me, because
most of queries to ContentType are done this way:

def some_view(request, content_type, *args, **kwargs):
    ctype = get_object_or_404(ContentType, model=content_type)

So this cache will not work. But, I've just thought, I don't need
generic solution and can
cache just by model name...

--
Alexander


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to