#30072: get_current cache uses global variable instead of cache breaking 
multiple
instance deployments.
-------------------------------+--------------------------------------
     Reporter:  lseelenbinder  |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  contrib.sites  |                  Version:  2.1
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Description changed by lseelenbinder:

Old description:

> I use the Sites framework extensively with a multiple instances of the
> application server deployment of Django. Because the sites framework uses
> a global to cache the current site, any update ''only'' affects whichever
> application server handled the update, leaving the outdated information
> cached on any other application servers.
>
> I would patch it to use the Django caching system instead of a global,
> but I'm not sure if that's the correct way to go about it.

New description:

 I use the Sites framework extensively with a multiple instances of the
 application server deployment of Django. Because the sites framework uses
 a global to cache the current site, any update ''only'' affects whichever
 application server handled the update, leaving the outdated information
 cached on any other application servers.

 I would patch it to use the Django caching system instead of a global, but
 I'm not sure if that's the correct way to go about it.

 Relevant code:
 
https://github.com/django/django/blob/master/django/contrib/sites/models.py#L103


 {{{
 #!python
 def clear_site_cache(sender, **kwargs):
     """
     Clear the cache (if primed) each time a site is saved or deleted.
     """
     instance = kwargs['instance']
     using = kwargs['using']
     try:
         del SITE_CACHE[instance.pk]
     except KeyError:
         pass
     try:
         del
 SITE_CACHE[Site.objects.using(using).get(pk=instance.pk).domain]
     except (KeyError, Site.DoesNotExist):
         pass
 }}}

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30072#comment:1>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.46c52a43cf23ce584a3d8f9019b512f4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to