qdk_chemistry.remote.cache.base module
Abstract cache backend for QDK/Chemistry job results.
Cache backends provide content-addressed storage for algorithm results, allowing repeated runs with identical inputs to skip execution entirely.
- qdk_chemistry.remote.cache.base.CoreDataClass
alias of
DataClass
- qdk_chemistry.remote.cache.base.is_cacheable(value)[source]
Return whether a value can be stored as a cache data entry.
- class qdk_chemistry.remote.cache.base.CacheBackend(*, is_shared=False)[source]
Bases:
ABCAbstract base class for result caches.
Implementations must provide these operations:
get_jobandput_jobpersistJobmetadata by run hash.get_dataandput_datastore supported values by content hash.delete_jobanddelete_dataremove cached metadata or blobs.clearremoves all cache entries.
- Parameters:
is_shared (
bool) – Set toTruewhen the backing store is reachable from multiple machines (e.g. a network-mounted folder). Defaults toFalse.
- __init__(*, is_shared=False)[source]
Initialise the cache backend.
- Parameters:
is_shared (bool)
- Return type:
None
- abstractmethod put_data(content_hash, data, *, shared_only=False)[source]
Store data by content hash, optionally requiring shared storage.
- abstractmethod delete_job(run_hash)[source]
Remove job metadata by run_hash. Returns
Trueif it existed.
- abstractmethod delete_data(content_hash)[source]
Remove a DataClass blob by content hash. Returns
Trueif it existed.
Whether this cache is reachable from both local and remote.
- has_data(content_hash, *, shared_only=False)[source]
Check whether a DataClass blob exists without deserializing it.
The default implementation calls
get_data()and checks forNone. Backends that can answer this more cheaply (e.g. aHEADrequest or aglob) should override. When shared_only is true, non-shared backends always returnFalse.
- to_config()[source]
Return constructor kwargs sufficient to recreate this backend.
Subclasses should override this if they accept configuration (paths, URLs, credentials, etc.). The default returns an empty dict, which is only valid for backends that need no arguments.
- Return type: