Flow ServerStarter
存储与消息

Redis

type redis

在设计器中打开 ↗

Redis 读写

使用说明

要点:Redis 基础读写,command 仅支持 SET / GET / DEL;key / value / expire 通过 CamelRedis.* Header 传递。
可选依赖该节点需要宿主额外引入 camel-spring-redis-starter,否则部署相关流程会在 Camel 启动路由阶段失败并回滚。

属性

字段类型必填默认值说明
command
命令
枚举 必填 GET
可选值:SET、GET、DEL
redisTemplate
RedisTemplate Bean
文本 可选 —
key
Key 表达式
表达式 必填 —
value
Value 表达式
表达式 可选 —
expire
过期时间表达式
表达式 可选 —

示例流程

可直接保存为 demo-redis.json 并部署;非入口节点默认套了一个 REST 入口。

Flow JSON
{
  "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"}'

相关节点