存储与消息
Redis 通用命令
type redisCommand
hash / list / publish / 计数器等命令
使用说明
要点:Redis 通用命令:hash / list / publish / 计数器等。field、start、end、expire 会写入对应 CamelRedis Header。
属性
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
command命令 |
枚举 | 必填 | GET |
|
redisTemplateRedisTemplate Bean |
文本 | 可选 | — | |
keyKey 表达式 |
表达式 | 必填 | — | |
valueValue 表达式 |
表达式 | 可选 | — | |
fieldHash Field 表达式 |
表达式 | 可选 | — | |
startLRANGE 起始下标 |
表达式 | 可选 | — | |
endLRANGE 结束下标 |
表达式 | 可选 | — | |
expire过期时间(秒) |
表达式 | 可选 | — |
示例流程
可直接保存为 demo-redisCommand.json 并部署;非入口节点默认套了一个 REST 入口。
{
"id": "demo-redisCommand",
"desc": "Redis 通用命令 示例",
"group": "示例/存储与消息",
"schemaVersion": 1,
"nodes": [
{
"id": "n1",
"type": "rest",
"props": {
"method": "POST",
"path": "/demo/redisCommand",
"desc": "示例入口"
}
},
{
"type": "redisCommand",
"props": {
"command": "HSET",
"key": {
"lang": "simple",
"script": "demo:hash"
},
"field": {
"lang": "constant",
"script": "userId"
},
"value": {
"lang": "simple",
"script": "${header.id}"
},
"expire": {
"lang": "constant",
"script": "3600"
}
},
"id": "n1"
}
]
}
curl -X POST 'http://localhost:8086/flow' \
-H 'Content-Type: application/json' \
-H 'X-Flow-Token: change-me' \
--data-binary @demo-redisCommand.json
调用方式
curl -X POST 'http://localhost:8086/demo/redisCommand' \
-H 'Content-Type: application/json' \
-d '{"id":1001}'