pynenc.arg_cache.base_arg_cache¶
Module Contents¶
Classes¶
Keys used in runner cache. |
|
Base class for argument caching system. |
API¶
- class pynenc.arg_cache.base_arg_cache.RunnerCacheKeys[source]¶
Bases:
enum.StrEnumKeys used in runner cache.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- ARG_CACHE_ID¶
‘auto(…)’
- ARG_CACHE_HASH¶
‘auto(…)’
- ARG_CACHE_FINGERPRINT¶
‘auto(…)’
- ARG_CACHE_KEY¶
‘auto(…)’
- ARG_CACHE_DESERIALIZED¶
‘auto(…)’
- class pynenc.arg_cache.base_arg_cache.BaseArgCache(app: pynenc.app.Pynenc)[source]¶
Bases:
abc.ABCBase class for argument caching system.
Caches large serialized arguments to avoid repeatedly sending them between tasks. Subclasses should implement the actual storage mechanism.
Initialization
Initialize with app reference.
- _initialize_caches() None[source]¶
Initialize cache sections if they don’t exist. Safe to call multiple times - won’t overwrite existing data. Works for both local and runner caches.
- _get_cache(key: pynenc.arg_cache.base_arg_cache.RunnerCacheKeys) dict[source]¶
Get the appropriate cache dictionary. Ensures caches are initialized.
- Parameters:
key (RunnerCacheKeys) – The cache section to access
- Returns:
The cache dictionary to use
- conf() pynenc.conf.config_arg_cache.ConfigArgCache¶
Get the argument cache configuration.
- _check_object_hash(obj: Any) tuple[str | None, int][source]¶
Try to get cached value using object hash. Returns (cached_key, obj_id) or (None, obj_id).
- _check_fingerprint(serialized: str, obj_id: int, obj: Any) str | None[source]¶
Check if serialized content matches by fingerprint.
- _check_exact_match(serialized: str, obj_id: int, obj: Any) tuple[str | None, tuple[str, int]][source]¶
Check if exact serialized content is cached. Returns (cached_key, fingerprint) or (None, fingerprint).
- _store_new_value(serialized: str, obj_id: int, obj: Any, fingerprint: tuple[str, int]) str[source]¶
Store new value and update all caches.
- serialize(obj: Any, disable_cache: bool = False) str[source]¶
Serialize an object, potentially caching if it meets size requirements.
- Parameters:
obj (Any) – Object to serialize
disable_cache (bool) – If True, skips caching regardless of size
- Returns:
Either the serialized string or a cache key
- deserialize(data: str) Any[source]¶
Deserialize data, checking if it’s a cache key first.
- Parameters:
data (str) – Data to deserialize (might be a cache key)
- Returns:
The deserialized object
- _update_obj_id_cache(obj_id: int, key: str) None[source]¶
Update the object ID cache with LRU eviction.
- _update_hash_cache(obj: Any, key: str) None[source]¶
Update the hash cache with LRU eviction if object is hashable.
- _update_fingerprint_cache(fingerprint: tuple[str, int], key: str) None[source]¶
Update the fingerprint cache with LRU eviction.
- _update_deserialized_cache(key: str, obj: Any) None[source]¶
Update the value cache with LRU eviction.
- purge() None[source]¶
Clear all cached arguments.
Should clear both the in-memory caches and the storage backend.