-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy path_client.py
More file actions
34 lines (26 loc) · 962 Bytes
/
_client.py
File metadata and controls
34 lines (26 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Redis storage driver client abstraction."""
from __future__ import annotations
from abc import ABC, abstractmethod
from datetime import timedelta
class RedisStorageDriverClient(ABC):
"""Abstract base class for the Redis operations used by the driver."""
@abstractmethod
async def get(self, *, key: str) -> bytes | None:
"""Return the raw bytes stored for *key*, or ``None`` if absent."""
@abstractmethod
async def set_if_absent(
self,
*,
key: str,
data: bytes,
ttl: timedelta | None = None,
) -> bool:
"""Store *data* under *key* only if the key does not already exist.
Args:
key: Redis key to store.
data: Serialized payload bytes.
ttl: Optional expiration to apply only when the value is inserted.
Returns:
``True`` if the value was inserted, ``False`` if the key already
existed.
"""