How to use the diskcache.memoize_stampede function in diskcache

To help you get started, we’ve selected a few diskcache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grantjenks / python-diskcache / tests / plot_early_recompute.py View on Github external
timer,
            cache.memoize(expire=1),
        ],
        ('Synchronized Locking', 'synchronized-locking.png'): [
            timer,
            cache.memoize(expire=0),
            dc.barrier(cache, dc.Lock),
            cache.memoize(expire=1),
        ],
        ('Early Recomputation', 'early-recomputation.png'): [
            timer,
            dc.memoize_stampede(cache, expire=1),
        ],
        ('Early Recomputation (beta=0.5)', 'early-recomputation-05.png'): [
            timer,
            dc.memoize_stampede(cache, expire=1, beta=0.5),
        ],
        ('Early Recomputation (beta=0.3)', 'early-recomputation-03.png'): [
            timer,
            dc.memoize_stampede(cache, expire=1, beta=0.3),
        ],
    }

    for (option, filename), decorators in options.items():
        print('Simulating:', option)
        worker_times = []
        worker = make_worker(worker_times)
        for decorator in reversed(decorators):
            worker = decorator(worker)

        worker()
        repeater = make_repeater(worker)
github grantjenks / python-diskcache / tests / plot_early_recompute.py View on Github external
('No Caching', 'no-caching.png'): [
            timer,
        ],
        ('Traditional Caching', 'traditional-caching.png'): [
            timer,
            cache.memoize(expire=1),
        ],
        ('Synchronized Locking', 'synchronized-locking.png'): [
            timer,
            cache.memoize(expire=0),
            dc.barrier(cache, dc.Lock),
            cache.memoize(expire=1),
        ],
        ('Early Recomputation', 'early-recomputation.png'): [
            timer,
            dc.memoize_stampede(cache, expire=1),
        ],
        ('Early Recomputation (beta=0.5)', 'early-recomputation-05.png'): [
            timer,
            dc.memoize_stampede(cache, expire=1, beta=0.5),
        ],
        ('Early Recomputation (beta=0.3)', 'early-recomputation-03.png'): [
            timer,
            dc.memoize_stampede(cache, expire=1, beta=0.3),
        ],
    }

    for (option, filename), decorators in options.items():
        print('Simulating:', option)
        worker_times = []
        worker = make_worker(worker_times)
        for decorator in reversed(decorators):