human
I wrote the below code

    def decorator(fx):
        fx.__cached = None
        fx.__cached_at = 0
        def wrapper(*args, **kwargs):
            dt = (time.time() - fx.__cached_at)
            if (((dt > duration) and (duration is not None)) or ((fx.__cached_at == 0) and (duration is None))):
                val = fx(*args, **kwargs)
                fx.__cached = val
                fx.__cached_at = time.time()
            else:
                val = fx.__cached
            return val
        wrapper.__doc__ = fx.__doc__
        return wrapper
    return decorator

What's a good function header?
assistant
#Here's a good function header.

@public
def cache_value(duration=None):