Last active
December 31, 2016 11:32
-
-
Save redrush85/7f1c807e886d8084f8332d9bf7129f17 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