Florian Iragne
unread,Aug 31, 2016, 5:54:21 AM8/31/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi,
I wanted to refactor my code using cache.get_or_set instead of using
cache.get and then check for None and so on
However, after a few tests, it seems that get_or_set does not work as
its name suggests: it is more get_or_add than get_or_set
Looking at the source code, it indeed does a get, then a add, not a set.
To my mind, the function name is misleading, even if after a careful
reading of the doc, it explains that the value is added (not set) if not
in the cache.
I haven't found anything about this, so i may be the only one astonished
by the difference between function name and function main behaviour.
However, i think it's useful to live a comment about this for other devs.
Cheers
Florian