idmtools.services.ipersistance_service module

IPersistenceService allows caching of items locally into a diskcache db that does not expire upon deletion.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

class idmtools.services.ipersistance_service.IPersistenceService

Bases: object

IPersistenceService provides a persistent cache. This is useful for network heavy operations.

cache_directory = None
cache_name = None
classmethod retrieve(uid)

Retrieve item with id <uid> from cache.

Parameters:

uid – Id to fetch

Returns:

Item loaded from cache

classmethod save(obj)

Save an item to our cache.

Parameters:

obj – Object to save.

Returns:

Object uid

classmethod delete(uid)

Delete at item from our cache with id <uid>.

Parameters:

uid – Id to delete

Returns:

None

classmethod clear()

Clear our cache.

Returns:

None

classmethod list()

List items in our cache.

Returns:

List of items in our cache

classmethod length()

Total length of our persistence cache.

Returns:

Count of our cache