内存键值存储,支持TTL,适用于 AI 代理。提供 Set、Get、Delete、List、Flush、Stats 操作;可存储任意 JSON 值,支持可选 TTL 及前缀键检索。
Lightweight key-value store for agent state, caching, and data sharing.
bash
uvicorn kvstore.app:app --port 8013
bash
curl -s -X POST http://localhost:8013/v1/set \
-H "Content-Type: application/json" \
-d '{"key": "user:1", "value": {"name": "Alice", "role": "admin"}}' | jq
bash
curl -s -X POST http://localhost:8013/v1/set \
-H "Content-Type: application/json" \
-d '{"key": "cache:token", "value": "abc123", "ttl_seconds": 3600}' | jq
bash
curl -s http://localhost:8013/v1/get/user:1 | jq
Returns key, value (any JSON), and ttl_remaining (seconds until expiry, or null).
bash
curl -s "http://localhost:8013/v1/keys?prefix=user:" | jq
bash
curl -s -X DELETE http://localhost:8013/v1/delete/user:1 | jq
curl -s -X POST http://localhost:8013/v1/flush | jq
curl -s http://localhost:8013/v1/stats | jq
MethodPathDescriptionPOST/v1/setSet a key-value pair (optional TTL)GET/v1/get/{key}Get value by keyDELETE/v1/delete/{key}Delete a keyGET/v1/keysList keys (optional ?prefix=)POST/v1/flushDelete all keysGET/v1/statsHit/miss counts and total keys