﻿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	Allow cache.get_or_set() to cache a None result	Phill Tornroth	Nick Pope	"`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()
        
    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	closed	Core (Cache system)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
