-
-
Save anonymous/725326d048e93066f8d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead of: | |
try: | |
app.memcache.delete(cache_key) | |
except AttributeError: | |
try: | |
env['swift.cache'].delete(cache_key) | |
except (KeyError, AttributeError): | |
pass | |
How about: | |
memcache = getattr(app, 'memcache', None) or env.get('swift.cache') | |
if memcache: | |
memcache.delete(cache_key) | |
Less than half the lines, no try/except overhead (albeit that's tiny), and no | |
repeated .delete call code. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment