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.
- class qdk_chemistry.remote.cache.base.CacheBackend(*, is_shared=False)[source]
Bases:
ABCAbstract base class for result caches.
Implementations must provide these operations:
get_job / put_job: persist
Jobmetadata keyed by the deterministic run_hash.get_data / put_data: content-addressed storage for
DataClassobjects. Primitives (floats, ints, …) are stored inline in the Job metadata and never touch these methods.delete_job / delete_data: remove cached metadata or blobs.
clear: remove all entries from the cache.
- Parameters:
is_shared (bool) – Set to
Truewhen 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 get_data(content_hash)[source]
Retrieve a DataClass object (or list) by its content hash, or
None.
- abstractmethod put_data(content_hash, data)[source]
Store a DataClass object (or list) by its content hash.
- 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)[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.