added redis adapter #1

Merged
brian merged 13 commits from collect-code-from-other-repos into main 2025-09-14 20:42:51 +02:00
4 changed files with 9 additions and 19 deletions
Showing only changes of commit 5d7afe7a6c - Show all commits
+2 -1
View File
@@ -1,5 +1,6 @@
"""python_repositories: Unified repository interfaces and adapters."""
from . import adapters
from . import interfaces
__all__ = ['adapters', 'interfaces']
__all__ = ["adapters", "interfaces"]
+3 -13
View File
@@ -43,17 +43,10 @@ class RedisAdapter(
return self
def __exit__(
self,
exc_type: type | None,
exc_val: object | None,
exc_tb: object | None
self, exc_type: type | None, exc_val: object | None, exc_tb: object | None
) -> None:
"""Exit the context."""
ctx_info = {
'exc_type': exc_type,
'exc_val': exc_val,
'exc_tb': exc_tb
}
ctx_info = {"exc_type": exc_type, "exc_val": exc_val, "exc_tb": exc_tb}
if any(
(
exc_type is not None,
@@ -148,9 +141,6 @@ class RedisAdapter(
list[bytes],
self._client.keys(pattern),
)
keys: list[str] = [
key.decode(self.encoding)
for key in keys_raw
]
keys: list[str] = [key.decode(self.encoding) for key in keys_raw]
self.logger.debug(f"Got {keys} matching {pattern}")
return keys
+3 -1
View File
@@ -1,4 +1,6 @@
from .connection_aware_interface import ConnectionAwareInterface as ConnectionAwareInterface
from .connection_aware_interface import (
ConnectionAwareInterface as ConnectionAwareInterface,
)
from .context_aware_interface import ContextAwareInterface as ContextAwareInterface
__all__ = [
@@ -15,10 +15,7 @@ class ContextAwareInterface(ABC):
@abstractmethod
def __exit__(
self,
exc_type: type | None,
exc_val: object | None,
exc_tb: object | None
self, exc_type: type | None, exc_val: object | None, exc_tb: object | None
) -> None:
"""Exit the context."""
raise NotImplementedError()