Async Basic 2¶
basic2.py¶
1import asyncio
2
3from typing import List
4from zcached.asyncio import AsyncZCached
5from zcached import Result
6
7
8async def main():
9 client: AsyncZCached = AsyncZCached(host="127.0.0.1", port=7556)
10 await client.run()
11
12 if not await client.is_alive():
13 raise RuntimeError("Something went wrong :(")
14
15 await client.set(key="dogs", value=["Pimpek", "Laika", "Pimpcio"])
16 response: Result[List[str]] = await client.get(key="dogs")
17
18 print(f"Result: {response.value}")
19 print(f"Error: {response.error}")
20
21
22if __name__ == "__main__":
23 asyncio.run(main())