Created
November 4, 2015 16:42
-
-
Save kgaughan/67674968e62c0912d1da to your computer and use it in GitHub Desktop.
retools caching example
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
import time | |
from retools.cache import cache_region, CacheRegion | |
@cache_region('short_term') | |
def myfunc(arg1): | |
print "In myfunc" | |
return 2 * arg1 | |
def main(): | |
CacheRegion.add_region('short_term', expires=2) | |
print "Answer is:", myfunc(5) | |
print "Answer is:", myfunc(10) | |
time.sleep(1) | |
print "Answer is:", myfunc(5) | |
time.sleep(1) | |
print "Answer is:", myfunc(5) | |
time.sleep(1) | |
print "Answer is:", myfunc(5) | |
print "Answer is:", myfunc(10) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment