How to use the diskcache.Index 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 / 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 / test_index.py View on Github external
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

    del index
    del other
    rmdir(directory)
    index = dc.Index(directory, mapping.items())

    assert index == mapping

    del index
    rmdir(directory)
    index = dc.Index(directory, a=5, b=4, c=3, d=2, e=1)

    assert index == mapping
github grantjenks / python-diskcache / tests / test_index.py View on Github external
assert index == mapping

    other = dc.Index(directory)

    assert other == index

    del index
    del other
    rmdir(directory)
    index = dc.Index(directory, mapping.items())

    assert index == mapping

    del index
    rmdir(directory)
    index = dc.Index(directory, a=5, b=4, c=3, d=2, e=1)

    assert index == mapping
github grantjenks / python-diskcache / tests / test_index.py View on Github external
del index

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

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

    other = dc.Index(directory)

    assert other == index

    del index
    del other
    rmdir(directory)
    index = dc.Index(directory, mapping.items())

    assert index == mapping

    del index
    rmdir(directory)
    index = dc.Index(directory, a=5, b=4, c=3, d=2, e=1)

    assert index == mapping
github JoneXiong / oejia_wx / rpc / base.py View on Github external
def init_data(self, env):
        from diskcache import Index
        self.dbname = env.cr.dbname
        self.UUID_OPENID = Index(self.get_path('UUID_OPENID'))
        self.OPENID_UUID = Index(self.get_path('OPENID_UUID'))
        self.OPENID_LAST = Index(self.get_path('OPENID_LAST'))
github JoneXiong / oejia_wx / rpc / base.py View on Github external
def init_data(self, env):
        from diskcache import Index
        self.dbname = env.cr.dbname
        self.UUID_OPENID = Index(self.get_path('UUID_OPENID'))
        self.OPENID_UUID = Index(self.get_path('OPENID_UUID'))
        self.OPENID_LAST = Index(self.get_path('OPENID_LAST'))