How to use diskcache - 10 common examples

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 / test_index.py View on Github external
def test_init():
    directory = '/tmp/diskcache/index'
    mapping = {'a': 5, 'b': 4, 'c': 3, 'd': 2, 'e': 1}
    index = dc.Index(None, mapping)

    assert index == mapping

    rmdir(index.directory)
    del index

    rmdir(directory)
    index = dc.Index(directory, mapping)

    assert index.directory == directory
    assert index == mapping

    other = dc.Index(directory)

    assert other == index
github grantjenks / python-diskcache / tests / stress_test_index_mp.py View on Github external
def test(status=False):
    random.seed(SEED)
    index = dc.Index(enumerate(range(KEYS)))
    processes = []

    for count in range(8):
        process = mp.Process(target=stress, args=(SEED + count, index))
        process.start()
        processes.append(process)

    for value in it.count():
        time.sleep(1)

        if status:
            print('\r', value, 's', len(index), 'keys', ' ' * 20, end='')

        if all(not process.is_alive() for process in processes):
            break
github grantjenks / python-diskcache / tests / stress_test_deque_mp.py View on Github external
def test(status=False):
    if os.environ.get('TRAVIS') == 'true':
        return

    if os.environ.get('APPVEYOR') == 'True':
        return

    random.seed(SEED)
    deque = dc.Deque(range(SIZE))
    processes = []

    for count in range(8):
        process = mp.Process(target=stress, args=(SEED + count, deque))
        process.start()
        processes.append(process)

    for value in it.count():
        time.sleep(1)

        if status:
            print('\r', value, 's', len(deque), 'items', ' ' * 20, end='')

        if all(not process.is_alive() for process in processes):
            break
github grantjenks / python-diskcache / tests / test_deque.py View on Github external
def test_init():
    directory = '/tmp/diskcache/deque'
    sequence = list('abcde')
    deque = dc.Deque(sequence, None)

    assert deque == sequence

    rmdir(deque.directory)
    del deque

    rmdir(directory)
    deque = dc.Deque(sequence, directory)

    assert deque.directory == directory
    assert deque == sequence

    other = dc.Deque(directory=directory)

    assert other == deque
github grantjenks / python-diskcache / tests / test_deque.py View on Github external
def test_init():
    directory = '/tmp/diskcache/deque'
    sequence = list('abcde')
    deque = dc.Deque(sequence, None)

    assert deque == sequence

    rmdir(deque.directory)
    del deque

    rmdir(directory)
    deque = dc.Deque(sequence, directory)

    assert deque.directory == directory
    assert deque == sequence

    other = dc.Deque(directory=directory)

    assert other == deque

    del deque
    del other
    rmdir(directory)
github grantjenks / python-diskcache / tests / test_ordered.py View on Github external
def test_init(cache):
    for key, value in dc.DEFAULT_SETTINGS.items():
        assert getattr(cache, key) == value

    cache.check()

    for key, value in dc.DEFAULT_SETTINGS.items():
        setattr(cache, key, value)

    cache.check()
github grantjenks / python-diskcache / tests / test_fanout.py View on Github external
def test_init(cache):
    default_settings = dc.DEFAULT_SETTINGS.copy()
    del default_settings['size_limit']
    for key, value in default_settings.items():
        assert getattr(cache, key) == value
    assert cache.size_limit == 2 ** 27

    cache.check()

    for key, value in dc.DEFAULT_SETTINGS.items():
        setattr(cache, key, value)

    cache.check()
github grantjenks / python-diskcache / tests / test_core.py View on Github external
def test_init(cache):
    for key, value in dc.DEFAULT_SETTINGS.items():
        assert getattr(cache, key) == value
    cache.check()
    cache.close()
    cache.close()
github grantjenks / python-diskcache / tests / test_fanout.py View on Github external
def test_init(cache):
    default_settings = dc.DEFAULT_SETTINGS.copy()
    del default_settings['size_limit']
    for key, value in default_settings.items():
        assert getattr(cache, key) == value
    assert cache.size_limit == 2 ** 27

    cache.check()

    for key, value in dc.DEFAULT_SETTINGS.items():
        setattr(cache, key, value)

    cache.check()
github grantjenks / python-diskcache / tests / test_ordered.py View on Github external
def test_init(cache):
    for key, value in dc.DEFAULT_SETTINGS.items():
        assert getattr(cache, key) == value

    cache.check()

    for key, value in dc.DEFAULT_SETTINGS.items():
        setattr(cache, key, value)

    cache.check()