CacheDict

class hybrid_learning.datasets.caching.CacheDict(cache_dict, return_none_if='any')[source]

Bases: CacheTuple

Cache the values of dicts using different caches. Under the hood this is a CacheTuple matching keys to caches.

Public Data Attributes:

cache_dict

The dictionary of caches used.

Public Methods:

load(descriptor)

Load a cached dict.

put(descriptor, obj)

Cache a dict.

Inherited from : py: class:CacheTuple

load(descriptor)

Load a cached dict.

put(descriptor, obj)

Cache a dict.

clear()

Clear all caches in the tuple.

descriptors()

Return all descriptors that occur in any of the given caches.

Inherited from : py: class:Cache

put(descriptor, obj)

Cache a dict.

load(descriptor)

Load a cached dict.

put_batch(descriptors, objs)

Store a batch of objs in this cache using according descriptors.

load_batch(descriptors[, return_none_if])

Load a batch of objects.

clear()

Clear all caches in the tuple.

descriptors()

Return all descriptors that occur in any of the given caches.

as_dict()

Return a dict with all cached descriptors and objects.

wrap(getitem[, descriptor_map])

Add this cache to the deterministic function getitem (which should have no side effects).

Special Methods:

__init__(cache_dict[, return_none_if])

Init.

__repr__()

Return repr(self).

Inherited from : py: class:CacheTuple

__init__(cache_dict[, return_none_if])

Init.

__repr__()

Return repr(self).

Inherited from : py: class:Cache

__repr__()

Return repr(self).

__add__(other)

Return a (cascaded) cache which will first lookup self then other with default sync mode.

__radd__(other)

Return a (cascaded) cache which will first lookup other then self with default sync mode.


Parameters
__init__(cache_dict, return_none_if='any')[source]

Init.

Parameters
__repr__()[source]

Return repr(self).

Return type

str

load(descriptor)[source]

Load a cached dict.

Parameters

descriptor (Hashable) –

Return type

Optional[Dict]

put(descriptor, obj)[source]

Cache a dict.

Parameters
property cache_dict: Dict[Hashable, Cache]

The dictionary of caches used.

keys: Tuple[Hashable]

The keys matching the caches. Caches are stored in caches.