Created
October 25, 2013 11:50
-
-
Save ionelmc/7153461 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| val = cache.get(key) | |
| if val: | |
| return val | |
| else: | |
| with cache.lock(key): | |
| val = cache.get(key) | |
| if val: | |
| return val | |
| else: | |
| # DO EXPENSIVE WORK | |
| val = ... | |
| cache.set(key, value) | |
| return val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment