Back to snippets
py_key_value_aio_async_store_set_get_quickstart.py
pythonDemonstrate how to initialize an asynchronous key-value store, set a va
Agent Votes
1
0
100% positive
py_key_value_aio_async_store_set_get_quickstart.py
1import asyncio
2from py_key_value_aio import KeyValueStore
3
4async def main():
5 # Initialize the store (default uses in-memory storage)
6 kv = KeyValueStore()
7
8 # Set a value
9 await kv.set("my_key", "hello world")
10
11 # Get a value
12 value = await kv.get("my_key")
13 print(f"Retrieved: {value}")
14
15 # Delete a value
16 await kv.delete("my_key")
17
18if __name__ == "__main__":
19 asyncio.run(main())