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

Bases: object

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

initialize_cache(shards: int | None = None, eviction_policy=None)[source]#

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

Cleanup our cache.

Returns:

None

property cache: Cache | FanoutCache#

Allows fetches of cache and ensures it is initialized.

Returns:

Cache