﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29867	cache.get_or_set won't cache None results	Phill Tornroth	nobody	"`get_or_set` docstring says ""If the key does not exist, add the key and set it to the default value."" -- but that's not quite what it does. It will perform a set if the key doesn't exist, ''or if the cached value is None''.

I think in order to be doing what it says on the tin it'd need to be:


{{{
if self.has_key(key, version=version):
        return self.get(key, version=version)
else:
    if callable(default):
        default = default()
    if default is not None:
        self.add(key, default, timeout=timeout, version=version)
        # Fetch the value again to avoid a race condition if another
        # caller added a value between the first get() and the add()
        # above.
        return self.get(key, default, version=version)
}}}

I'd find this useful in cases where None was an expensive result to arrive at. If there's spiritual alignment with the suggestion, I'm happy to prepare and submit a change with tests."	Bug	new	Core (Cache system)	2.1	Normal				Unreviewed	0	0	0	0	0	0
