360 Secure SkillHub
360 安全技能中心

Kvstore

这是专为AI Agent流水线设计的轻量内存型键值存储,可用于状态管理、缓存与数据共享。核心功能含键值增删改查、批量清空、前缀列键、存储统计,支持任意JSON值及单键TTL自动过期。通过HTTP接口以JSON格式交互,可通过curl快速调用,是轻量化Redis替代方案。

mirni
mirni
热度 36.74
最近更新 2026-05-11 17:42:52
分类:开发依赖:代码执行应用场景:API 集成 / 数据处理 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add gh-kvstore
Metadata
name
gh-kvstore
description
In-memory key-value store with TTL for AI agents. Set, get, delete, list, flush, and stats. Supports any JSON value, optional TTL per key, and prefix-based key listing. Like a lightweight Redis for agent pipelines.
metadata
{"openclaw":{"emoji":"🗄️","requires":{"bins":["python"]},"install":[{"id":"pip","kind":"uv","packages":["fastapi","uvicorn","pydantic"]}]}}

KVStore

Lightweight key-value store for agent state, caching, and data sharing.

Start the server

uvicorn kvstore.app:app --port 8013

Set a value

curl -s -X POST http://localhost:8013/v1/set \
  -H "Content-Type: application/json" \
  -d '{"key": "user:1", "value": {"name": "Alice", "role": "admin"}}' | jq

Set with TTL (auto-expires)

curl -s -X POST http://localhost:8013/v1/set \
  -H "Content-Type: application/json" \
  -d '{"key": "cache:token", "value": "abc123", "ttl_seconds": 3600}' | jq

Get a value

curl -s http://localhost:8013/v1/get/user:1 | jq

Returns key, value (any JSON), and ttl_remaining (seconds until expiry, or null).

List keys by prefix

curl -s "http://localhost:8013/v1/keys?prefix=user:" | jq

Delete / Flush / Stats

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

Endpoints

Method Path Description
POST /v1/set Set a key-value pair (optional TTL)
GET /v1/get/{key} Get value by key
DELETE /v1/delete/{key} Delete a key
GET /v1/keys List keys (optional ?prefix=)
POST /v1/flush Delete all keys
GET /v1/stats Hit/miss counts and total keys