idmtools.core.cache_enabled module

CacheEnabled definition. CacheEnabled enables diskcache wrapping on an item.

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

class idmtools.core.cache_enabled.CacheEnabled

Bases: object

Allows a class to leverage Diskcache and expose a cache property.

initialize_cache(shards: Optional[int] = None, eviction_policy=None)

Initialize cache.

Parameters:
  • shards (Optional[int], optional) – How many shards. It is best to set this when multi-procressing Defaults to None.

  • eviction_policy ([type], optional) – See Diskcache docs. Defaults to None.

cleanup_cache()

Cleanup our cache.

Returns:

None

property cache: Union[Cache, FanoutCache]

Allows fetches of cache and ensures it is initialized.

Returns:

Cache