name: agentuity-cli-cloud-keyvalue-set description: 在键值存储中设置键和值。需要身份验证。用于Agentuity云平台操作 version: “0.0.103” license: Apache-2.0 allowed-tools: “Bash(agentuity:*)” argument-hint: “<namespace> <key> <value> [ttl]” metadata: command: “agentuity cloud keyvalue set” tags: “mutating updates-resource slow requires-auth”
云键值设置
在键值存储中设置键和值
前提条件
- 已通过
agentuity auth login进行身份验证 - 需要项目上下文(从项目目录运行或使用
--project-id)
使用方法
agentuity cloud keyvalue set <namespace> <key> <value> [ttl]
参数
| 参数 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
<namespace> |
字符串 | 是 | - |
<key> |
字符串 | 是 | - |
<value> |
字符串 | 是 | - |
<ttl> |
字符串 | 否 | - |
示例
存储用户数据:
bunx @agentuity/cli kv set production user:123 '{"name":"Alice","email":"alice@example.com"}'
存储会话数据,TTL为1小时:
bunx @agentuity/cli kv set cache session:abc "session-data-here" --ttl 3600
缓存主页数据10分钟:
bunx @agentuity/cli kv set staging cache:homepage "<!DOCTYPE html>..." --ttl 600
输出
返回JSON对象:
{
"success": "boolean",
"namespace": "string",
"key": "string",
"contentType": "string",
"durationMs": "number",
"ttl": "number"
}
| 字段 | 类型 | 描述 |
|---|---|---|
success |
布尔值 | 操作是否成功 |
namespace |
字符串 | 命名空间名称 |
key |
字符串 | 键名称 |
contentType |
字符串 | 内容类型(application/json 或 text/plain) |
durationMs |
数字 | 操作持续时间(毫秒) |
ttl |
数字 | 如果设置了TTL,则为TTL秒数 |