def cache(timeout, *, key_func=None):
    """Caches a function results for timeout seconds."""
    if isinstance(timeout, timedelta):
        timeout = timeout.total_seconds()

    return _memory_decorator(CacheMemory(timeout), key_func)
Caches a function results for timeout seconds.
funcy/calc.py