Opened 8 years ago
Closed 8 years ago
#26792 closed Cleanup/optimization (fixed)
Allow None for the value of cache.get_or_set()
Reported by: | Dmitry S..ky / skype: dvska-at-skype | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | d.v.selitsky@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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_whose_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
Change History (5)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
Cc: | added |
---|
comment:3 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 8 years ago
Summary: | cache.get_or_set() calculates the default key value in case it is already cached → Allow None for the value of cache.get_or_set() |
---|---|
Type: | Bug → Cleanup/optimization |
comment:5 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
In 82be474: