So I just faced the case in which I tried to delete a key from a cache definition which wasn’t actually there (given the way I tested the code, I had been always trying to delete things that had been previously created by me… yes, silly me). And it turns out I got an error instead of… nothing.
The code would be:
# Invalidate the cache cache_key = 'id:%s' % id_ cache = self.cache.get_cache('builtin', 'logins') cache.delete(cache_key)
I have checked the docs but I have not found about a potential parameter which would let me instruct the cache API to fail silently, i.e. “it’s okay if you cannot delete it (because it doesn’t exist)”.
Of course I could check whether it’s there before trying to delete it, but it would require two I/O operations.
What do you think, @dsuch? Worth adding an extra parameter there, in case it’s not already there?