Source code for pynenc.arg_cache.disabled_arg_cache
from typing import TYPE_CHECKING, Any
from pynenc.arg_cache.base_arg_cache import BaseArgCache
if TYPE_CHECKING:
from pynenc.app import Pynenc
[docs]
class DisabledArgCache(BaseArgCache):
"""
A no-op implementation of argument caching that passes through to the serializer.
This is the default implementation used when argument caching is not needed.
"""
def __init__(self, app: "Pynenc") -> None:
self.app = app
# Do not call super().__init__(app) to avoid runner cache initialization
[docs]
def serialize(self, obj: Any, disable_cache: bool = False) -> str:
"""Direct passthrough to serializer."""
return self.app.serializer.serialize(obj)
[docs]
def deserialize(self, data: str) -> Any:
"""Direct passthrough to serializer."""
return self.app.serializer.deserialize(data)
[docs]
def _store(self, key: str, value: str) -> None:
"""Not used in disabled cache."""
raise NotImplementedError("DisabledArgCache does not support storing values.")
[docs]
def _retrieve(self, key: str) -> str:
"""Not used in disabled cache."""
raise NotImplementedError(
"DisabledArgCache does not support retrieving values."
)
[docs]
def is_cache_key(self, value: str) -> bool:
"""Always returns False for disabled cache."""
return False