Last active
December 28, 2016 16:51
-
-
Save redrush85/3d3d637c39879f8be97a96233d244f92 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
def async_cached(cache, key=hashkey): | |
def decorator(fn): | |
async def wrapper(*args, **kwargs): | |
k = key(*args, **kwargs) | |
if k not in cache: | |
result = await fn(*args, **kwargs) | |
if result is None: | |
return result | |
cache[k] = result | |
return cache[k] | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment