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[source]#

Bases: object

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

cache_directory = None#
cache_name = None#
classmethod retrieve(uid)[source]#

Retrieve item with id <uid> from cache.

Parameters:

uid – Id to fetch

Returns:

Item loaded from cache

classmethod save(obj)[source]#

Save an item to our cache.

Parameters:

obj – Object to save.

Returns:

Object uid

classmethod delete(uid)[source]#

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

Parameters:

uid – Id to delete

Returns:

None

classmethod clear()[source]#

Clear our cache.

Returns:

None

classmethod list()[source]#

List items in our cache.

Returns:

List of items in our cache

classmethod length()[source]#

Total length of our persistence cache.

Returns:

Count of our cache