{"id":161717,"date":"2024-11-04T08:45:43","date_gmt":"2024-11-04T00:45:43","guid":{"rendered":"https:\/\/server.hk\/cnblog\/161717\/"},"modified":"2024-11-04T08:45:44","modified_gmt":"2024-11-04T00:45:44","slug":"%e5%9f%ba%e6%96%bc-spring-cloud-apache-ignite-%e7%9a%84-redis-%e5%82%99%e7%94%a8%e6%96%b9%e6%a1%88%e5%af%a6%e4%be%8b%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/161717\/","title":{"rendered":"\u57fa\u65bc Spring Cloud + Apache Ignite \u7684 Redis \u5099\u7528\u65b9\u6848\u5be6\u4f8b\u6559\u7a0b"},"content":{"rendered":"<h1 id=\"%e5%9f%ba%e6%96%bc-spring-cloud-apache-ignite-%e7%9a%84-redis-%e5%82%99%e7%94%a8%e6%96%b9%e6%a1%88%e5%af%a6%e4%be%8b%e6%95%99%e7%a8%8b-hCngaXREfh\">\u57fa\u65bc Spring Cloud + Apache Ignite \u7684 Redis \u5099\u7528\u65b9\u6848\u5be6\u4f8b\u6559\u7a0b<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u5fae\u670d\u52d9\u67b6\u69cb\u4e2d\uff0c\u6578\u64da\u7684\u9ad8\u53ef\u7528\u6027\u548c\u5feb\u901f\u5b58\u53d6\u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002Redis \u4f5c\u70ba\u4e00\u500b\u9ad8\u6548\u7684\u9375\u503c\u5b58\u5132\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u7de9\u5b58\u548c\u6578\u64da\u5b58\u5132\u3002\u7136\u800c\uff0cRedis \u7684\u55ae\u9ede\u6545\u969c\u554f\u984c\u4f7f\u5f97\u8a31\u591a\u4f01\u696d\u5c0b\u6c42\u66f4\u53ef\u9760\u7684\u89e3\u6c7a\u65b9\u6848\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u57fa\u65bc Spring Cloud \u548c Apache Ignite \u5be6\u73fe Redis \u7684\u5099\u7528\u65b9\u6848\uff0c\u5f9e\u800c\u63d0\u9ad8\u7cfb\u7d71\u7684\u7a69\u5b9a\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%81%b8%e6%93%87-apache-ignite-%e4%bd%9c%e7%82%ba-redis-%e7%9a%84%e5%82%99%e7%94%a8%e6%96%b9%e6%a1%88-hCngaXREfh\">\u70ba\u4ec0\u9ebc\u9078\u64c7 Apache Ignite \u4f5c\u70ba Redis \u7684\u5099\u7528\u65b9\u6848<\/h2>\n<p>Apache Ignite \u662f\u4e00\u500b\u5206\u4f48\u5f0f\u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u4e86\u9ad8\u6027\u80fd\u7684\u6578\u64da\u5b58\u5132\u548c\u8a08\u7b97\u80fd\u529b\u3002\u5b83\u7684\u7279\u9ede\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u9ad8\u53ef\u7528\u6027\uff1a<\/strong>\u652f\u6301\u6578\u64da\u7684\u81ea\u52d5\u5206\u7247\u548c\u8907\u88fd\uff0c\u78ba\u4fdd\u6578\u64da\u5728\u591a\u500b\u7bc0\u9ede\u4e4b\u9593\u7684\u5197\u9918\u3002<\/li>\n<li><strong>\u5feb\u901f\u5b58\u53d6\uff1a<\/strong>\u5167\u5b58\u4e2d\u7684\u6578\u64da\u8655\u7406\u901f\u5ea6\u6975\u5feb\uff0c\u9069\u5408\u9700\u8981\u4f4e\u5ef6\u9072\u7684\u61c9\u7528\u3002<\/li>\n<li><strong>\u8207 Spring Cloud \u7684\u6574\u5408\uff1a<\/strong>\u53ef\u4ee5\u8f15\u9b06\u5730\u8207\u5fae\u670d\u52d9\u67b6\u69cb\u96c6\u6210\uff0c\u5be6\u73fe\u9748\u6d3b\u7684\u6578\u64da\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-hCngaXREfh\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6e96\u5099\u4ee5\u4e0b\u74b0\u5883\uff1a<\/p>\n<ul>\n<li>Java 8 \u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<li>Maven 3.6 \u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<li>Apache Ignite 2.8 \u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<li>Spring Boot 2.5 \u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<\/ul>\n<h2 id=\"%e9%a0%85%e7%9b%ae%e7%b5%90%e6%a7%8b-hCngaXREfh\">\u9805\u76ee\u7d50\u69cb<\/h2>\n<p>\u9996\u5148\uff0c\u5275\u5efa\u4e00\u500b\u65b0\u7684 Spring Boot \u9805\u76ee\uff0c\u4e26\u5728 pom.xml \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4f9d\u8cf4\uff1a<\/p>\n<pre><code>\n&lt;dependency&gt;\n    &lt;groupId&gt;org.apache.ignite&lt;\/groupId&gt;\n    &lt;artifactId&gt;ignite-spring&lt;\/artifactId&gt;\n    &lt;version&gt;2.8.1&lt;\/version&gt;\n&lt;\/dependency&gt;\n&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\n<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-apache-ignite-hCngaXREfh\">\u914d\u7f6e Apache Ignite<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e Apache Ignite\u3002\u5728 src\/main\/resources \u76ee\u9304\u4e0b\u5275\u5efa\u4e00\u500b ignite-config.xml \u6587\u4ef6\uff0c\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>\n&lt;bean id=\"ignite.cfg\" class=\"org.apache.ignite.configuration.IgniteConfiguration\"&gt;\n    &lt;property name=\"igniteInstanceName\" value=\"ignite-instance\"\/&gt;\n    &lt;property name=\"discoverySpi\"&gt;\n        &lt;bean class=\"org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi\"&gt;\n            &lt;property name=\"ipFinder\"&gt;\n                &lt;bean class=\"org.apache.ignite.spi.discovery.tcp.TcpDiscoveryIpFinder\"&gt;\n                    &lt;property name=\"addresses\"&gt;\n                        &lt;list&gt;\n                            &lt;value&gt;127.0.0.1:47500&lt;\/value&gt;\n                        &lt;\/list&gt;\n                    &lt;\/property&gt;\n                &lt;\/bean&gt;\n            &lt;\/property&gt;\n        &lt;\/bean&gt;\n    &lt;\/property&gt;\n&lt;\/bean&gt;\n<\/code><\/pre>\n<h2 id=\"%e5%af%a6%e7%8f%be-redis-%e7%9a%84%e5%82%99%e7%94%a8%e6%96%b9%e6%a1%88-hCngaXREfh\">\u5be6\u73fe Redis \u7684\u5099\u7528\u65b9\u6848<\/h2>\n<p>\u5728\u60a8\u7684\u670d\u52d9\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Apache Ignite \u4f5c\u70ba Redis \u7684\u5099\u7528\u65b9\u6848\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5c07\u6578\u64da\u5b58\u5132\u5230 Ignite \u4e2d\uff1a<\/p>\n<pre><code>\nimport org.apache.ignite.Ignite;\nimport org.apache.ignite.Ignition;\nimport org.apache.ignite.cache.CacheEntryProcessor;\nimport org.apache.ignite.configuration.CacheConfiguration;\n\npublic class IgniteExample {\n    public static void main(String[] args) {\n        Ignite ignite = Ignition.start(\"ignite-config.xml\");\n\n        CacheConfiguration&lt;String, String&gt; cacheCfg = new CacheConfiguration&lt;&gt;(\"myCache\");\n        ignite.getOrCreateCache(cacheCfg);\n\n        ignite.cache(\"myCache\").put(\"key1\", \"value1\");\n        String value = ignite.cache(\"myCache\").get(\"key1\");\n\n        System.out.println(\"Stored value: \" + value);\n    }\n}\n<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-hCngaXREfh\">\u7d50\u8ad6<\/h2>\n<p>\u901a\u904e\u5c07 Apache Ignite \u8207 Spring Cloud \u7d50\u5408\u4f7f\u7528\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a Redis \u7684\u55ae\u9ede\u6545\u969c\u554f\u984c\uff0c\u5be6\u73fe\u9ad8\u53ef\u7528\u6027\u548c\u5feb\u901f\u5b58\u53d6\u7684\u6578\u64da\u7ba1\u7406\u65b9\u6848\u3002\u9019\u7a2e\u67b6\u69cb\u4e0d\u50c5\u80fd\u5920\u63d0\u9ad8\u7cfb\u7d71\u7684\u7a69\u5b9a\u6027\uff0c\u9084\u80fd\u5920\u5728\u9762\u5c0d\u9ad8\u4e26\u767c\u8acb\u6c42\u6642\u4fdd\u6301\u826f\u597d\u7684\u6027\u80fd\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u90e8\u7f72\u60a8\u7684\u61c9\u7528\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u5ba2\u6236\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u57fa\u65bc Spring Cloud \u548c Apache Ignite \u7684 Redis \u5099\u7528\u65b9\u6848\uff0c\u63d0\u4f9b\u5be6\u4f8b\u6559\u7a0b\uff0c\u52a9\u60a8\u8f15\u9b06\u5be6\u73fe\u9ad8\u6548\u6578\u64da\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-161717","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/161717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=161717"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/161717\/revisions"}],"predecessor-version":[{"id":161718,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/161717\/revisions\/161718"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=161717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=161717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=161717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}