How to use the diskcache.barrier 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
cache_times = []
    timer = make_timer(cache_times)

    options = {
        ('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),
        ],
    }