def _cache(f):
    """Decorator to cache return value of a function."""
    cached = {}

    def cached_function():
        """Cache return value in closure before calling function."""
        if 'value' not in cached:
            cached['value'] = f()
        return cached['value']

    return cached_function