#29340: "cache.get_or_set()" extra hits on database
-------------------------------------+-------------------------------------
     Reporter:  hematinik            |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Core (Cache system)  |                  Version:  2.0
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  cache                |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

 The second block evaluates `event.location` (which causes a database
 query) because it's an argument to `cache.get_or_set()`. The first block
 delays that evaluation until the cache is checked (`cache.get()`). This is
 how Python works and not a bug in Django.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29340#comment:6>
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/067.7abb3538b2cc5c456114f4857368494b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to