def __call__(self, func):
        cache = self._cache
        expire = self._expire

        ft.wraps(func)
        def wrapper(*args, **kwargs):
            "Wrapper function to cache function result."
            key = (args, kwargs)

            try:
                result, expire_time, delta = cache.get(
                    key, default=ENOVAL, expire_time=True, tag=True
                )

                if result is ENOVAL:
                    raise KeyError

                now = time.time()
                ttl = expire_time - now

                if (-delta * math.log(random.random())) < ttl:
                    return result

            except KeyError:
                pass

            now = time.time()
            result = func(*args, **kwargs)
            delta = time.time() - now
            cache.set(key, result, expire=expire, tag=delta)

            return result

        return wrapper
dataset/ETHPy150Open grantjenks/python-diskcache/diskcache/stampede.py/StampedeBarrier.__call__/original