Files
task-001/memory_client.py
2026-05-27 08:29:49 +00:00

34 lines
965 B
Python

"""
Memory Client implementation.
This module provides a simple client that interacts with the MemoryServer via a local function call interface. In real deployments, this could be replaced with network communication (e.g., gRPC or HTTP).
"""
from typing import Any
from memory_server import MemoryServer
class MemoryClient:
"""A thin wrapper around MemoryServer.
The client holds a reference to a :class:`MemoryServer` instance and forwards operations.
"""
def __init__(self, server: MemoryServer) -> None:
self._server = server
def set(self, key: str, value: Any) -> None:
self._server.set(key, value)
def get(self, key: str) -> Any:
return self._server.get(key)
def delete(self, key: str) -> None:
self._server.delete(key)
# Simple demo when run as a script
if __name__ == "__main__":
srv = MemoryServer()
cli = MemoryClient(srv)
cli.set("bar", [1, 2, 3])
print(cli.get("bar"))