| 33 | |
| 34 | |
| 35 | class DictCache(BaseCache): |
| 36 | def __init__(self, init_dict: MutableMapping[str, bytes] | None = None) -> None: |
| 37 | self.lock = Lock() |
| 38 | self.data = init_dict or {} |
| 39 | |
| 40 | def get(self, key: str) -> bytes | None: |
| 41 | return self.data.get(key, None) |
| 42 | |
| 43 | def set( |
| 44 | self, key: str, value: bytes, expires: int | datetime | None = None |
| 45 | ) -> None: |
| 46 | with self.lock: |
| 47 | self.data.update({key: value}) |
| 48 | |
| 49 | def delete(self, key: str) -> None: |
| 50 | with self.lock: |
| 51 | if key in self.data: |
| 52 | self.data.pop(key) |
| 53 | |
| 54 | |
| 55 | class SeparateBodyBaseCache(BaseCache): |
no outgoing calls
searching dependent graphs…