#26792: cache.get_or_set() calculates the default key value in case it is
already
cached
-------------------------------------+--------------------
Reporter: dvska | Owner: nobody
Type: Bug | Status: new
Component: Core (Cache system) | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+--------------------
The check "if default is None" causing an unconditional calculation of the
default value.
Behaviour before patch:
{{{
def heavy_routine_whose_result_to_be_cached():
return todays_weather_forecast_calculated
...
cache.set('todays_weather_forecast',
heavy_routine_which_result_to_be_cached())
...
val = cache.get_or_set('todays_weather_forecast',
heavy_routine_which_result_to_be_cached()) ## calculates 2nd time, which
is unwanted behaviour
}}}
Proposed patch -> https://github.com/django/django/pull/6824
--
Ticket URL: <https://code.djangoproject.com/ticket/26792>
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/048.14084da222fda6a91244d33b4c8a3f41%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.