存储与消息
Redis
type redis
Redis 读写
使用说明
要点:Redis 基础读写,command 仅支持 SET / GET / DEL;key / value / expire 通过 CamelRedis.* Header 传递。
属性
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
command命令 |
枚举 | 必填 | GET |
|
redisTemplateRedisTemplate Bean |
文本 | 可选 | — | |
keyKey 表达式 |
表达式 | 必填 | — | |
valueValue 表达式 |
表达式 | 可选 | — | |
expire过期时间表达式 |
表达式 | 可选 | — |
示例流程
可直接保存为 demo-redis.json 并部署;非入口节点默认套了一个 REST 入口。
{
"id": "demo-redis",
"desc": "Redis 示例",
"group": "示例/存储与消息",
"schemaVersion": 1,
"nodes": [
{
"id": "n1",
"type": "rest",
"props": {
"method": "POST",
"path": "/demo/redis",
"desc": "示例入口"
}
},
{
"type": "redis",
"props": {
"command": "SET",
"key": {
"lang": "simple",
"script": "demo:user:${header.id}"
},
"value": {
"lang": "simple",
"script": "${body}"
},
"expire": {
"lang": "constant",
"script": "60"
}
},
"id": "n1"
}
]
}
curl -X POST 'http://localhost:8086/flow' \
-H 'Content-Type: application/json' \
-H 'X-Flow-Token: change-me' \
--data-binary @demo-redis.json
调用方式
curl -X POST 'http://localhost:8086/demo/redis' \
-H 'Content-Type: application/json' \
-d '{"id":1,"name":"alice"}'