#28601: do not cache default callable return value of None in get_or_set ------------------------------------------------+------------------------ Reporter: Dan Tao | Owner: nobody Type: Cleanup/optimization | Status: new Component: Core (Cache system) | Version: 1.11 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | ------------------------------------------------+------------------------ In [82be474 https://github.com/django/django/commit/82be474efa81e5f2e127d711045a2ec06b206a8e] the change was made to allow None as a default value passed to BaseCache.get_or_set. In case the default value of None is used, it is not stored in the cache. This still left open the possibility that default could be a callable that returns None, in which case it would be stored in the cache.
{{{ # This scenario works as expected. cache.get_or_set('foo', None) # None cache.get_or_set('foo', 5) # 5 cache.get('foo') # 5 # This scenario seems wrong. cache.get_or_set('bar', lambda: None) # None cache.get_or_set('bar', 5) # None :( cache.get('bar') # None :( }}} -- Ticket URL: <https://code.djangoproject.com/ticket/28601> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/047.a34271c3aca9215d1d35a4a21e135bc9%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.