A time-to-live caching decorator that follows after the style of
    lru_cache.  The `maxage` argument is time-to-live in seconds for each
    cache result.  Any cache entries over the maxage are lazily replaced.

def ttl_cache(maxage, maxsize=128):
    """ A time-to-live caching decorator that follows after the style of
    lru_cache.  The `maxage` argument is time-to-live in seconds for each
    cache result.  Any cache entries over the maxage are lazily replaced. """

    def decorator(inner_func):
        wrapper = make_ttl_cache_wrapper(inner_func, maxage, maxsize)
        return functools.update_wrapper(wrapper, inner_func)
    return decorator