1"use strict";(self.webpackChunkspring_ai_alibaba_website=self.webpackChunkspring_ai_alibaba_website||[]).push([[4099],{28453:(n,e,i)=>{i.d(e,{R:()=>o,x:()=>t});var a=i(96540);const r={},s=a.createContext(r);function o(n){const e=a.useContext(s);return a.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function t(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:o(n.components),a.createElement(s.Provider,{value:e},n.children)}},50320:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>l,contentTitle:()=>t,default:()=>p,frontMatter:()=>o,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"frameworks/graph-core/examples/checkpoint-redis","title":"Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316","description":"\u4f7f\u7528 Redis \u6570\u636e\u5e93\u6301\u4e45\u5316\u548c\u7ba1\u7406 Spring AI Alibaba Graph \u5de5\u4f5c\u6d41\u72b6\u6001\uff0c\u5b9e\u73b0\u8de8\u6267\u884c\u7684\u72b6\u6001\u4fdd\u6301","source":"@site/docs/frameworks/graph-core/examples/checkpoint-redis.md","sourceDirName":"frameworks/graph-core/examples","slug":"/frameworks/graph-core/examples/checkpoint-redis","permalink":"/docs/frameworks/graph-core/examples/checkpoint-redis","draft":false,"unlisted":false,"editUrl":"https://github.com/spring-ai-alibaba/website/tree/main/docs/frameworks/graph-core/examples/checkpoint-redis.md","tags":[],"version":"current","lastUpdatedBy":"Ken Liu","lastUpdatedAt":1763556354000,"frontMatter":{"title":"Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316","description":"\u4f7f\u7528 Redis \u6570\u636e\u5e93\u6301\u4e45\u5316\u548c\u7ba1\u7406 Spring AI Alibaba Graph \u5de5\u4f5c\u6d41\u72b6\u6001\uff0c\u5b9e\u73b0\u8de8\u6267\u884c\u7684\u72b6\u6001\u4fdd\u6301","keywords":["Spring AI Alibaba","Redis","Checkpoint","\u68c0\u67e5\u70b9","\u6301\u4e45\u5316","\u72b6\u6001\u7ba1\u7406","\u5de5\u4f5c\u6d41\u72b6\u6001"]},"sidebar":"docsSidebar","previous":{"title":"\u4e3a\u56fe\u6dfb\u52a0\u6301\u4e45\u5316\uff08\u8bb0\u5fc6\uff09","permalink":"/docs/frameworks/graph-core/examples/persistence"},"next":{"title":"\u65f6\u5149\u65c5\u884c - \u72b6\u6001\u5386\u53f2\u56de\u6eaf","permalink":"/docs/frameworks/graph-core/examples/time-travel"}}');var r=i(74848),s=i(28453);const o={title:"Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316",description:"\u4f7f\u7528 Redis \u6570\u636e\u5e93\u6301\u4e45\u5316\u548c\u7ba1\u7406 Spring AI Alibaba Graph \u5de5\u4f5c\u6d41\u72b6\u6001\uff0c\u5b9e\u73b0\u8de8\u6267\u884c\u7684\u72b6\u6001\u4fdd\u6301",keywords:["Spring AI Alibaba","Redis","Checkpoint","\u68c0\u67e5\u70b9","\u6301\u4e45\u5316","\u72b6\u6001\u7ba1\u7406","\u5de5\u4f5c\u6d41\u72b6\u6001"]},t="Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316",l={},d=[{value:"\u6982\u8ff0",id:"\u6982\u8ff0",level:2},{value:"\u529f\u80fd\u7279\u6027",id:"\u529f\u80fd\u7279\u6027",level:2},{value:"\u8981\u6c42",id:"\u8981\u6c42",level:2},{value:"\u5feb\u901f\u5f00\u59cb",id:"\u5feb\u901f\u5f00\u59cb",level:2},{value:"\u6dfb\u52a0\u4f9d\u8d56",id:"\u6dfb\u52a0\u4f9d\u8d56",level:3},{value:"\u521d\u59cb\u5316 RedisSaver",id:"\u521d\u59cb\u5316-redissaver",level:3},{value:"\u5b8c\u6574\u793a\u4f8b",id:"\u5b8c\u6574\u793a\u4f8b",level:3},{value:"Spring Boot \u914d\u7f6e",id:"spring-boot-\u914d\u7f6e",level:3},{value:"\u6570\u636e\u5b58\u50a8",id:"\u6570\u636e\u5b58\u50a8",level:2},{value:"\u9ad8\u7ea7\u7528\u6cd5",id:"\u9ad8\u7ea7\u7528\u6cd5",level:2},{value:"\u6062\u590d\u5de5\u4f5c\u6d41",id:"\u6062\u590d\u5de5\u4f5c\u6d41",level:3},{value:"\u67e5\u8be2\u5386\u53f2\u72b6\u6001",id:"\u67e5\u8be2\u5386\u53f2\u72b6\u6001",level:3},{value:"\u4ece\u7279\u5b9a\u68c0\u67e5\u70b9\u6062\u590d",id:"\u4ece\u7279\u5b9a\u68c0\u67e5\u70b9\u6062\u590d",level:3},{value:"\u6027\u80fd\u4f18\u5316",id:"\u6027\u80fd\u4f18\u5316",level:2},{value:"\u6545\u969c\u6392\u9664",id:"\u6545\u969c\u6392\u9664",level:2},{value:"\u8fde\u63a5\u95ee\u9898",id:"\u8fde\u63a5\u95ee\u9898",level:3},{value:"\u5185\u5b58\u95ee\u9898",id:"\u5185\u5b58\u95ee\u9898",level:3},{value:"\u6700\u4f73\u5b9e\u8df5",id:"\u6700\u4f73\u5b9e\u8df5",level:2},{value:"\u603b\u7ed3",id:"\u603b\u7ed3",level:2}];function c(n){const e={blockquote:"blockquote",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...n.components},{Code:i}
1=e;return i||function(n,e){throw new Error("Expected "+(e?"component":"object")+" `"+n+"` to be defined: you likely forgot to import, pass, or provide it.")}("Code",!0),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.header,{children:(0,r.jsx)(e.h1,{id:"redis-\u68c0\u67e5\u70b9\u6301\u4e45\u5316",children:"Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316"})}),"\n",(0,r.jsxs)(e.blockquote,{children:["\n",(0,r.jsx)(e.p,{children:"\u5728 Redis \u6570\u636e\u5e93\u4e2d\u6301\u4e45\u5316\u548c\u7ba1\u7406\u60a8\u7684 Spring AI Alibaba Graph \u5de5\u4f5c\u6d41\u72b6\u6001\uff0c\u786e\u4fdd\u6301\u4e45\u6027"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6982\u8ff0",children:"\u6982\u8ff0"}),"\n",(0,r.jsx)(e.p,{children:"Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316\u662f Spring AI Alibaba Graph \u751f\u6001\u7cfb\u7edf\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u5b83\u4f7f\u5f97\u5de5\u4f5c\u6d41\u72b6\u6001\u80fd\u591f\u53ef\u9760\u5730\u5b58\u50a8\u5728 Redis \u6570\u636e\u5e93\u4e2d\u3002\u8fd9\u4f7f\u60a8\u57fa\u4e8e LLM \u7684\u5e94\u7528\u7a0b\u5e8f\u5728\u6267\u884c\u4e4b\u95f4\u4fdd\u6301\u72b6\u6001\u2014\u2014\u786e\u4fdd\u5de5\u4f5c\u6d41\u8fdb\u5ea6\u4e0d\u4f1a\u4e22\u5931\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u4efb\u4f55\u65f6\u5019\u6062\u590d\u6216\u5206\u6790\u3002"}),"\n",(0,r.jsx)(e.p,{children:"\u4e3b\u8981\u7279\u6027\u5305\u62ec\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u57fa\u4e8e Redis \u7684\u6301\u4e45\u5316"}),"\uff1a\u6240\u6709\u5de5\u4f5c\u6d41\u72b6\u6001\u90fd\u5b58\u50a8\u5728 Redis \u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u5728\u8fdb\u7a0b\u91cd\u542f\u6216\u7cfb\u7edf\u6545\u969c\u540e\u4fdd\u5b58\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u9ad8\u6027\u80fd\u5b58\u50a8"}),"\uff1a\u5229\u7528 Redis \u7684\u5185\u5b58\u5b58\u50a8\u7279\u6027\uff0c\u63d0\u4f9b\u6781\u5feb\u7684\u8bfb\u5199\u6027\u80fd\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u81ea\u52a8\u8fc7\u671f\u7ba1\u7406"}),"\uff1a\u652f\u6301 TTL\uff08Time To Live\uff09\u914d\u7f6e\uff0c\u81ea\u52a8\u6e05\u7406\u8fc7\u671f\u7684\u68c0\u67e5\u70b9\u6570\u636e\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u529f\u80fd\u7279\u6027",children:"\u529f\u80fd\u7279\u6027"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u6301\u4e45\u5316\u72b6\u6001"}),"\uff1a\u6301\u4e45\u5316 Spring AI Alibaba Graph \u5de5\u4f5c\u6d41\u7684\u6574\u4e2a\u72b6\u6001\uff0c\u5141\u8bb8\u968f\u65f6\u7ee7\u7eed\u6216\u6062\u590d\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u9ad8\u6027\u80fd\u8bbf\u95ee"}),"\uff1a\u5229\u7528 Redis \u7684\u5185\u5b58\u5b58\u50a8\u548c\u6570\u636e\u7ed3\u6784\uff0c\u63d0\u4f9b\u6beb\u79d2\u7ea7\u7684\u8bbf\u95ee\u901f\u5ea6\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u7075\u6d3b\u7684\u914d\u7f6e"}),"\uff1a\u652f\u6301\u5355\u673a\u3001\u54e8\u5175\u3001\u96c6\u7fa4\u7b49\u591a\u79cd Redis \u90e8\u7f72\u6a21\u5f0f\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u65e0\u7f1d\u96c6\u6210"}),"\uff1a\u5f00\u7bb1\u5373\u7528\u5730\u4e0e Spring AI Alibaba Graph \u7684\u72b6\u6001\u7ba1\u7406\u548c\u5de5\u4f5c\u6d41 API \u914d\u5408\u4f7f\u7528\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u8981\u6c42",children:"\u8981\u6c42"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"Redis \u6570\u636e\u5e93"}),"\uff1a\u63a8\u8350\u7248\u672c 6.0 \u6216\u66f4\u9ad8\u3002"]}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Java 17+"})}),"\n",(0,r.jsx)(e.li,{children:(0,r.jsx)(e.strong,{children:"Spring AI Alibaba Graph \u6838\u5fc3\u5e93"})}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"Redisson \u5ba2\u6237\u7aef"}),"\uff1a\u7528\u4e8e\u4e0e Redis \u4ea4\u4e92"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u5feb\u901f\u5f00\u59cb",children:"\u5feb\u901f\u5f00\u59cb"}),"\n",(0,r.jsx)(e.h3,{id:"\u6dfb\u52a0\u4f9d\u8d56",children:"\u6dfb\u52a0\u4f9d\u8d56"}),"\n",(0,r.jsx)(e.p,{children:"\u5728\u60a8\u7684\u9879\u76ee\u6784\u5efa\u914d\u7f6e\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"Maven"})}),"\n",(0,r.jsx)(i,{language:"xml",children:"\n\x3c!-- Redisson \u5ba2\u6237\u7aef\u4f9d\u8d56 --\x3e\n<dependency>\n <groupId>org.redisson</groupId>\n <artifactId>redisson</artifactId>\n <version>3.22.0</version>\n</dependency>"}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.strong,{children:"Gradle"})}),"\n",(0,r.jsx)(i,{language:"gradle",children:"implementation 'com.alibaba.cloud.ai:spring-ai-alibaba-graph-checkpoint-redis:1.0.0.3-SNAPSHOT'\nimplementation 'org.redisson:redisson:3.24.3'"}),"\n",(0,r.jsx)(e.h3,{id:"\u521d\u59cb\u5316-redissaver",children:"\u521d\u59cb\u5316 RedisSaver"}),"\n",(0,r.jsx)(e.p,{children:"RedisSaver \u4f7f\u7528 Redisson \u5ba2\u6237\u7aef\u8fdb\u884c\u914d\u7f6e\u3002\u60a8\u9700\u8981\u5148\u914d\u7f6e Redisson \u5ba2\u6237\u7aef\uff0c\u7136\u540e\u521b\u5efa RedisSaver\u3002"}),"\n",(0,r.jsx)(i,{language:"java",title:"\u521d\u59cb\u5316 RedisSaver",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'import
1com.alibaba.cloud.ai.graph.checkpoint.config.SaverConfig;\nimport com.alibaba.cloud.ai.graph.checkpoint.savers.RedisSaver;\nimport org.redisson.Redisson;\nimport org.redisson.api.RedissonClient;\nimport org.redisson.config.Config;\n\n// \u914d\u7f6e Redisson \u5ba2\u6237\u7aef\nConfig config = new Config();\nconfig.useSingleServer()\n .setAddress("redis://localhost:6379"); // Redis \u5730\u5740\n\nRedissonClient redisson = Redisson.create(config);\n\n// \u521d\u59cb\u5316 Redis Saver\nRedisSaver saver = new RedisSaver(redisson);\n\n// \u914d\u7f6e Saver\nSaverConfig saverConfig = SaverConfig.builder()\n .register(saver)\n .build();'}),"\n",(0,r.jsx)(e.h3,{id:"\u5b8c\u6574\u793a\u4f8b",children:"\u5b8c\u6574\u793a\u4f8b"}),"\n",(0,r.jsx)(e.p,{children:"\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528 Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316\u6765\u4fdd\u5b58\u3001\u91cd\u65b0\u52a0\u8f7d\u548c\u9a8c\u8bc1\u5de5\u4f5c\u6d41\u72b6\u6001\u7684\u5b8c\u6574\u793a\u4f8b\uff1a"}),"\n",(0,r.jsx)(i,{language:"java",title:"\u5b8c\u6574\u793a\u4f8b",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'import com.alibaba.cloud.ai.graph.CompileConfig;\nimport com.alibaba.cloud.ai.graph.CompiledGraph;\nimport com.alibaba.cloud.ai.graph.KeyStrategy;\nimport com.alibaba.cloud.ai.graph.KeyStrategyFactory;\nimport com.alibaba.cloud.ai.graph.OverAllState;\nimport com.alibaba.cloud.ai.graph.RunnableConfig;\nimport com.alibaba.cloud.ai.graph.StateGraph;\nimport com.alibaba.cloud.ai.graph.checkpoint.config.SaverConfig;\nimport com.alibaba.cloud.ai.graph.checkpoint.savers.RedisSaver;\nimport com.alibaba.cloud.ai.graph.exception.GraphStateException;\nimport com.alibaba.cloud.ai.graph.state.StateSnapshot;\nimport com.alibaba.cloud.ai.graph.state.strategy.ReplaceStrategy;\n\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.redisson.Redisson;\nimport org.redisson.api.RedissonClient;\nimport org.redisson.config.Config;\n\nimport static com.alibaba.cloud.ai.graph.StateGraph.END;\nimport static com.alibaba.cloud.ai.graph.StateGraph.START;\nimport static com.alibaba.cloud.ai.graph.action.AsyncNodeAction.node_async;\n\npublic class RedisCheckpointExample {\n\n public void testCheckpointWithRedis() throws Exception {\n // \u521d\u59cb\u5316 Redis Saver\n Config config = new Config();\n config.useSingleServer()\n .setAddress("redis://localhost:6379");\n\n RedissonClient redisson = Redisson.create(config);\n RedisSaver saver = new RedisSaver(redisson);\n\n SaverConfig saverConfig = SaverConfig.builder()\n .register(saver)\n .build();\n\n // \u5b9a\u4e49\u72b6\u6001\u7b56\u7565\n KeyStrategyFactory keyStrategyFactory = () -> {\n Map<String, KeyStrategy> keyStrategyMap = new HashMap<>();\n keyStrategyMap.put("input", new ReplaceStrategy());\n keyStrategyMap.put("agent_1:prop1", new ReplaceStrategy());\n return keyStrategyMap;\n };\n\n // \u5b9a\u4e49\u8282\u70b9\n var agent1 = node_async(state -> {\n System.out.println("agent_1 \u6267\u884c\u4e2d");\n return Map.of("agent_1:prop1", "agent_1:test");\n });\n\n // \u6784\u5efa\u56fe\n StateGraph stateGraph = new StateGraph(keyStrategyFactory)\n .addNode("agent_1", agent1)\n .addEdge(START, "agent_1")\n .addEdge("agent_1", END);\n\n // \u4f7f\u7528\u68c0\u67e5\u70b9\u7f16\u8bd1\u56fe\n CompiledGraph workflow = stateGraph.compile(\n CompileConfig.builder()\n .saverConfig(saverConfig)\n .build()\n );\n\n // \u6267\u884c\u5de5\u4f5c\u6d41\n RunnableConfig runnableConfig = RunnableConfig.builder()\n .threadId("test-thread-1")\n .build();\n\n Map<String, Object> inputs = Map.of("input", "test1");\n OverAllState result = workflow.invoke(inputs, runnableConfig).orElseThrow();\n\n // \u83b7\u53d6\u68c0\u67e5\u70b9\u5386\u53f2\n List<StateSnapshot> history = (List<StateSnapshot>) workflow.getStateHistory(runnableConfig);\n\n System.out.println("\u68c0\u67e5\u70b9\u5386\u53f2\u6570\u91cf: " + history.size());\n\n // \u83b7\u53d6\u6700\u540e\u4fdd\u5b58\u7684\u68c0\u67e5\u70b9\n StateSnapshot lastSnapshot = workflow.getState(runnableConfig);\n\n System.out.println("\u6700\u540e\u68c0\u67e5\u70b9\u8282\u70b9: " + lastSnapshot.no
1de());\n\n // \u6d4b\u8bd5\u4ece Redis \u91cd\u65b0\u52a0\u8f7d\u68c0\u67e5\u70b9\n // \u521b\u5efa\u65b0\u7684 saver\uff08\u91cd\u7f6e\u7f13\u5b58\uff09\n Config newConfig = new Config();\n newConfig.useSingleServer()\n .setAddress("redis://localhost:6379");\n\n RedissonClient newRedisson = Redisson.create(newConfig);\n RedisSaver newSaver = new RedisSaver(newRedisson);\n\n SaverConfig newSaverConfig = SaverConfig.builder()\n .register(newSaver)\n .build();\n\n // \u91cd\u65b0\u7f16\u8bd1\u56fe\n CompiledGraph reloadedWorkflow = stateGraph.compile(\n CompileConfig.builder()\n .saverConfig(newSaverConfig)\n .build()\n );\n\n // \u4f7f\u7528\u76f8\u540c\u7684 threadId \u83b7\u53d6\u5386\u53f2\n RunnableConfig reloadConfig = RunnableConfig.builder()\n .threadId("test-thread-1")\n .build();\n\n Collection<StateSnapshot> reloadedHistory = reloadedWorkflow.getStateHistory(reloadConfig);\n\n System.out.println("\u91cd\u65b0\u52a0\u8f7d\u7684\u68c0\u67e5\u70b9\u5386\u53f2\u6570\u91cf: " + reloadedHistory.size());\n }\n}'}),"\n",(0,r.jsx)(e.h3,{id:"spring-boot-\u914d\u7f6e",children:"Spring Boot \u914d\u7f6e"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c\u60a8\u4f7f\u7528 Spring Boot\uff0c\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e Redis \u8fde\u63a5\uff1a"}),"\n",(0,r.jsx)(i,{language:"yaml",title:"application.yml",children:"spring:\nredis:\n host: localhost\n port: 6379\n password: # \u53ef\u9009\uff0c\u5982\u679c Redis \u8bbe\u7f6e\u4e86\u5bc6\u7801\n database: 0"}),"\n",(0,r.jsx)(e.p,{children:"\u7136\u540e\u5728\u914d\u7f6e\u7c7b\u4e2d\u521b\u5efa RedisSaver Bean\uff1a"}),"\n",(0,r.jsx)(i,{language:"java",title:"Spring Boot \u914d\u7f6e\u7c7b",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'import org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.beans.factory.annotation.Value;\nimport org.redisson.Redisson;\nimport org.redisson.api.RedissonClient;\nimport org.redisson.config.Config;\nimport com.alibaba.cloud.ai.graph.checkpoint.config.SaverConfig;\nimport com.alibaba.cloud.ai.graph.checkpoint.savers.RedisSaver;\n\n@Configuration\npublic class GraphCheckpointConfig {\n\n @Value("${spring.redis.host}")\n private String redisHost;\n\n @Value("${spring.redis.port}")\n private int redisPort;\n\n @Value("${spring.redis.password:}")\n private String redisPassword;\n\n @Bean\n public RedissonClient redissonClient() {\n Config config = new Config();\n config.useSingleServer()\n .setAddress(String.format("redis://%s:%d", redisHost, redisPort));\n \n if (redisPassword != null && !redisPassword.isEmpty()) {\n config.useSingleServer().setPassword(redisPassword);\n }\n \n return Redisson.create(config);\n }\n\n @Bean\n public RedisSaver redisSaver(RedissonClient redissonClient) {\n return new RedisSaver(redissonClient);\n }\n\n @Bean\n public SaverConfig saverConfig(RedisSaver redisSaver) {\n return SaverConfig.builder()\n .register(redisSaver)\n .build();\n }\n}'}),"\n",(0,r.jsx)(e.h2,{id:"\u6570\u636e\u5b58\u50a8",children:"\u6570\u636e\u5b58\u50a8"}),"\n",(0,r.jsx)(e.p,{children:"Redis \u68c0\u67e5\u70b9\u5668\u4f7f\u7528\u4ee5\u4e0b\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u5de5\u4f5c\u6d41\u72b6\u6001\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"Hash \u7ed3\u6784"}),"\uff1a\u5b58\u50a8\u6bcf\u4e2a\u68c0\u67e5\u70b9\u7684\u5b8c\u6574\u72b6\u6001\u6570\u636e"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"Sorted Set"}),"\uff1a\u7528\u4e8e\u5b58\u50a8\u68c0\u67e5\u70b9\u7684\u5143\u6570\u636e\u548c\u6392\u5e8f\u4fe1\u606f"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"String"}),"\uff1a\u5b58\u50a8\u68c0\u67e5\u70b9\u7684\u5e8f\u5217\u5316\u72b6\u6001"]}),"\n"]}),"\n",(0,r.jsx)(e.p,{children:"Redis \u4f1a\u81ea\u52a8\u7ba1\u7406\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\uff0c\u65e0\u9700\u624b\u52a8\u521b\u5efa\u8868\u6216 schema\u3002"}),"\n",(0,r.jsx)(e.h2,{id:"\u9ad8\u7ea7\u7528\u6cd5",children:"\u9ad8\u7ea7\u7528\u6cd5"}),"\n",(0,r.jsx)(e.h3,{id:"\u6062\u590d\u5de5\u4f5c\u6d41",children:"\u6062\u590d\u5de5\u4f5c\u6d41"}),"\n",(0,r.jsx)(e.p,{children:"\u4ece Redis \u6062\u590d\u5de5\u4f5c\u6d41\u975e\u5e38\u7b80\u5355\uff1a"}),"\n",(0,r.jsx)(i,{language:"java",title:"\u6062\u590d\u5de5\u4f5c\u6d41",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'import
1com.alibaba.cloud.ai.graph.CompiledGraph;\nimport com.alibaba.cloud.ai.graph.RunnableConfig;\n\nimport java.util.Map;\n\n// \u4f7f\u7528\u76f8\u540c\u7684 threadId\nRunnableConfig config = RunnableConfig.builder()\n .threadId("original-thread-id")\n .build();\n\n// \u4ece\u4e0a\u6b21\u68c0\u67e5\u70b9\u7ee7\u7eed\u6267\u884c\nworkflow.invoke(Map.of(), config);'}),"\n",(0,r.jsx)(e.h3,{id:"\u67e5\u8be2\u5386\u53f2\u72b6\u6001",children:"\u67e5\u8be2\u5386\u53f2\u72b6\u6001"}),"\n",(0,r.jsx)(i,{language:"java",title:"\u67e5\u8be2\u5386\u53f2\u72b6\u6001",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'import com.alibaba.cloud.ai.graph.CompiledGraph;\nimport com.alibaba.cloud.ai.graph.RunnableConfig;\nimport com.alibaba.cloud.ai.graph.state.StateSnapshot;\n\nimport java.util.List;\n\n// \u83b7\u53d6\u6240\u6709\u5386\u53f2\u72b6\u6001\nList<StateSnapshot> history = (List<StateSnapshot>) workflow.getStateHistory(config);\n\n// \u904d\u5386\u5386\u53f2\nfor (StateSnapshot snapshot : history) {\n System.out.println("\u8282\u70b9: " + snapshot.node());\n System.out.println("\u72b6\u6001: " + snapshot.state());\n System.out.println("Checkpoint ID: " + snapshot.config().checkPointId());\n}'}),"\n",(0,r.jsx)(e.h3,{id:"\u4ece\u7279\u5b9a\u68c0\u67e5\u70b9\u6062\u590d",children:"\u4ece\u7279\u5b9a\u68c0\u67e5\u70b9\u6062\u590d"}),"\n",(0,r.jsx)(i,{language:"java",title:"\u4ece\u7279\u5b9a\u68c0\u67e5\u70b9\u6062\u590d",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'import com.alibaba.cloud.ai.graph.CompiledGraph;\nimport com.alibaba.cloud.ai.graph.RunnableConfig;\n\nimport java.util.Map;\n\n// \u83b7\u53d6\u7279\u5b9a\u68c0\u67e5\u70b9\nRunnableConfig checkpointConfig = RunnableConfig.builder()\n .threadId("thread-id")\n .checkPointId("specific-checkpoint-id")\n .build();\n\n// \u4ece\u8be5\u68c0\u67e5\u70b9\u7ee7\u7eed\nworkflow.invoke(Map.of(), checkpointConfig);\nSystem.out.println("\u4ece\u68c0\u67e5\u70b9\u6062\u590d\u6267\u884c\u5b8c\u6210");'}),"\n",(0,r.jsx)(e.h2,{id:"\u6027\u80fd\u4f18\u5316",children:"\u6027\u80fd\u4f18\u5316"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u8fde\u63a5\u6c60"}),"\uff1aRedisson \u81ea\u52a8\u7ba1\u7406\u8fde\u63a5\u6c60\uff0c\u4f18\u5316 Redis \u8fde\u63a5\u6027\u80fd\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u5185\u5b58\u4f18\u5316"}),"\uff1a\u5408\u7406\u914d\u7f6e Redis \u5185\u5b58\u9650\u5236\uff0c\u907f\u514d\u5185\u5b58\u6ea2\u51fa\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"TTL \u8bbe\u7f6e"}),"\uff1a\u4e3a\u68c0\u67e5\u70b9\u6570\u636e\u8bbe\u7f6e\u5408\u7406\u7684\u8fc7\u671f\u65f6\u95f4\uff0c\u81ea\u52a8\u6e05\u7406\u65e7\u6570\u636e\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u6279\u91cf\u64cd\u4f5c"}),"\uff1a\u5229\u7528 Redis Pipeline \u51cf\u5c11\u7f51\u7edc\u5f80\u8fd4\u6b21\u6570\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u6301\u4e45\u5316\u914d\u7f6e"}),"\uff1a\u6839\u636e\u9700\u6c42\u914d\u7f6e RDB \u6216 AOF \u6301\u4e45\u5316\u7b56\u7565\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6545\u969c\u6392\u9664",children:"\u6545\u969c\u6392\u9664"}),"\n",(0,r.jsx)(e.h3,{id:"\u8fde\u63a5\u95ee\u9898",children:"\u8fde\u63a5\u95ee\u9898"}),"\n",(0,r.jsx)(e.p,{children:"\u786e\u4fdd Redis \u670d\u52a1\u5668\u53ef\u8bbf\u95ee\u4e14\u8fde\u
163a5\u53c2\u6570\u6b63\u786e\uff1a"}),"\n",(0,r.jsx)(i,{language:"java",title:"\u6d4b\u8bd5\u8fde\u63a5",sourceUrl:"https://github.com/alibaba/spring-ai-alibaba/tree/main/examples/documentation/src/main/java/com/alibaba/cloud/ai/examples/documentation/graph/examples/CheckpointRedisExample.java",children:'// \u6d4b\u8bd5 Redis \u8fde\u63a5\ntry {\n Config config = new Config();\n config.useSingleServer()\n .setAddress("redis://localhost:6379");\n \n RedissonClient redisson = Redisson.create(config);\n \n // \u6267\u884c\u7b80\u5355\u7684 ping \u64cd\u4f5c\u6d4b\u8bd5\u8fde\u63a5\n redisson.getKeys().count();\n System.out.println("Redis \u8fde\u63a5\u6210\u529f\uff01");\n \n redisson.shutdown();\n} catch (Exception e) {\n System.err.println("Redis \u8fde\u63a5\u5931\u8d25: " + e.getMessage());\n}'}),"\n",(0,r.jsx)(e.h3,{id:"\u5185\u5b58\u95ee\u9898",children:"\u5185\u5b58\u95ee\u9898"}),"\n",(0,r.jsx)(e.p,{children:"\u5982\u679c\u9047\u5230\u5185\u5b58\u4e0d\u8db3\u7684\u9519\u8bef\uff1a"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\u68c0\u67e5 Redis \u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff1a",(0,r.jsx)(e.code,{children:"redis-cli info memory"})]}),"\n",(0,r.jsx)(e.li,{children:"\u914d\u7f6e Redis \u6700\u5927\u5185\u5b58\u9650\u5236"}),"\n",(0,r.jsx)(e.li,{children:"\u4e3a\u68c0\u67e5\u70b9\u6570\u636e\u8bbe\u7f6e\u5408\u7406\u7684 TTL"}),"\n",(0,r.jsx)(e.li,{children:"\u8003\u8651\u4f7f\u7528 Redis \u96c6\u7fa4\u6a21\u5f0f\u5206\u6563\u5185\u5b58\u538b\u529b"}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u6700\u4f73\u5b9e\u8df5",children:"\u6700\u4f73\u5b9e\u8df5"}),"\n",(0,r.jsxs)(e.ol,{children:["\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u552f\u4e00\u7684\u7ebf\u7a0b ID"}),"\uff1a\u4e3a\u6bcf\u4e2a\u72ec\u7acb\u7684\u5de5\u4f5c\u6d41\u5b9e\u4f8b\u4f7f\u7528\u552f\u4e00\u7684\u7ebf\u7a0b ID\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u5b9a\u671f\u5907\u4efd"}),"\uff1a\u914d\u7f6e Redis \u6301\u4e45\u5316\uff08RDB \u6216 AOF\uff09\u4ee5\u9632\u6b62\u6570\u636e\u4e22\u5931\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u76d1\u63a7"}),"\uff1a\u76d1\u63a7 Redis \u5185\u5b58\u4f7f\u7528\u3001\u8fde\u63a5\u6570\u548c\u6027\u80fd\u6307\u6807\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"TTL \u7b56\u7565"}),"\uff1a\u4e3a\u68c0\u67e5\u70b9\u6570\u636e\u8bbe\u7f6e\u5408\u7406\u7684\u8fc7\u671f\u65f6\u95f4\uff0c\u81ea\u52a8\u6e05\u7406\u65e7\u6570\u636e\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u5b89\u5168\u6027"}),"\uff1a\u4f7f\u7528 Redis \u5bc6\u7801\u8ba4\u8bc1\uff0c\u9650\u5236\u7f51\u7edc\u8bbf\u95ee\uff0c\u542f\u7528 TLS \u52a0\u5bc6\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u9ad8\u53ef\u7528"}),"\uff1a\u751f\u4ea7\u73af\u5883\u5efa\u8bae\u4f7f\u7528 Redis Sentinel \u6216 Cluster \u6a21\u5f0f\u3002"]}),"\n",(0,r.jsxs)(e.li,{children:[(0,r.jsx)(e.strong,{children:"\u5185\u5b58\u7ba1\u7406"}),"\uff1a\u5408\u7406\u914d\u7f6e Redis \u6700\u5927\u5185\u5b58\u548c\u6dd8\u6c70\u7b56\u7565\u3002"]}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"\u603b\u7ed3",children:"\u603b\u7ed3"}),"\n",(0,r.jsx)(e.p,{children:"Redis \u68c0\u67e5\u70b9\u6301\u4e45\u5316\u4e3a Spring AI Alibaba Graph \u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u72b6\u6001\u7ba1\u7406\u89e3\u51b3\u65b9\u6848\uff0c\u4f7f\u60a8\u7684 AI \u5e94\u7528\u7a0b\u5e8f\u80fd\u591f\u5728\u6545\u969c\u540e\u6062\u590d\uff0c\u5b9e\u73b0\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u5de5\u4f5c\u6d41\uff0c\u5e76\u652f\u6301\u4eba\u5728\u56de\u8def\u4e2d\u7684\u4ea4\u4e92\u3002\u901a\u8fc7\u5229\u7528 Redis \u7684\u5185\u5b58\u5b58\u50a8\u7279\u6027\u548c\u9ad8\u6027\u80fd\uff0c\u60a8\u53ef\u4ee5\u6784\u5efa\u5065\u58ee\u7684\u3001\u751f\u4ea7\u7ea7\u7684 AI \u5e94\u7528\u7a0b\u5e8f\u3002Redis \u7684\u5feb\u901f\u8bfb\u5199\u80fd\u529b\u548c\u7075\u6d3b\u7684\u6570\u636e\u7ed3\u6784\u4f7f\u5176\u6210\u4e3a\u68c0\u67e5\u70b9\u6301\u4e45\u5316\u7684\u7406\u60f3\u9009\u62e9\u3002"})]})}function p(n={}){const{wrapper:e}={...(0,s.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(c,{...n})}):c(n)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.