{"id":4842,"date":"2024-08-01T22:48:00","date_gmt":"2024-08-01T14:48:00","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=4842"},"modified":"2024-08-01T22:48:00","modified_gmt":"2024-08-01T14:48:00","slug":"%e9%9d%a2%e8%af%95%e7%af%87%ef%bc%9aredis-%e5%88%86%e5%b8%83%e5%bc%8f%e9%94%81%e7%9a%84%e6%ad%a3%e7%a1%ae%e5%ae%9e%e7%8e%b0%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/%e9%9d%a2%e8%af%95%e7%af%87%ef%bc%9aredis-%e5%88%86%e5%b8%83%e5%bc%8f%e9%94%81%e7%9a%84%e6%ad%a3%e7%a1%ae%e5%ae%9e%e7%8e%b0%e6%96%b9%e5%bc%8f\/","title":{"rendered":"\u9762\u8bd5\u7bc7\uff1aRedis \u5206\u5e03\u5f0f\u9501\u7684\u6b63\u786e\u5b9e\u73b0\u65b9\u5f0f"},"content":{"rendered":"<div class='wxsyncmain'>\n<section style=\"margin-left: 6px;margin-right: 6px;line-height: 1.75em;\">\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0px;font-size: 15px;outline: 0px;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;visibility: visible;\" data-mpa-powered-by=\"yiban.io\" data-style=\"outline: 0px; font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); text-align: center;\" class=\"js_darkmode__0\"><span style=\"color: rgb(136, 136, 136);outline: 0px;letter-spacing: 0.544px;font-size: 14px;visibility: visible;\">\u70b9\u51fb\u201c<\/span><span style=\"outline: 0px;letter-spacing: 0.544px;font-size: 14px;visibility: visible;\"><font color=\"#007aaa\">\u7801\u8bed<\/font><\/span><span style=\"color: rgb(136, 136, 136);outline: 0px;letter-spacing: 0.544px;font-size: 14px;visibility: visible;\">\u201d\uff0c<\/span><span style=\"color: rgb(255, 169, 0);outline: 0px;letter-spacing: 0.544px;font-size: 14px;visibility: visible;\" data-style=\"outline: 0px; letter-spacing: 0.544px; font-size: 14px; color: rgb(255, 169, 0);\" class=\"js_darkmode__1\">\u5173\u6ce8\uff0c\u7f6e\u9876<\/span><span style=\"color: rgb(136, 136, 136);outline: 0px;letter-spacing: 0.544px;font-size: 14px;visibility: visible;\">\u516c\u4f17\u53f7<\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;outline: 0px;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;visibility: visible;\" data-style=\"outline: 0px; font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); text-align: center;\" class=\"js_darkmode__2\"><span><span style=\"outline: 0px;color: rgb(136, 136, 136);font-size: 14px;letter-spacing: 0.544px;visibility: visible;\">\u6bcf\u65e5\u6280\u672f\u5e72\u8d27\uff0c\u7b2c\u4e00\u65f6\u95f4\u9001\u8fbe\uff01<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><\/span><\/p>\n<section data-class=\"_mbEditor\" data-id=\"132148\" style=\"visibility: visible;\">\n<section data-tools-id=\"46476\" style=\"visibility: visible;\">\n<section style=\"font-family: Arial;border-width: 0px 0px 2px;border-style: none none solid;color: rgb(49, 147, 105);border-color: rgb(239, 112, 96);visibility: visible;\">\n<p placeholder=\"1\" style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;font-size: 15px;border-radius: 80% 100% 90% 20%;color: rgb(255, 255, 255);float: left;line-height: 20px;margin-right: 8px;padding: 4px 10px;background-color: rgb(239, 112, 96);visibility: visible;\"><span>1<\/span><\/p>\n<p style=\"unicode-bidi: embed;margin: 1.12em 0;display: inline-block;font-weight: bold;font-size: 16px;line-height: 28px;color: rgb(239, 112, 96);min-height: 32px;visibility: visible;\"><span>\u524d\u8a00<\/span><\/p>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"font-size: 16px;visibility: visible;\">\u5206\u5e03\u5f0f\u9501\u4e00\u822c\u6709\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff1a<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"font-size: 16px;visibility: visible;\">1. \u6570\u636e\u5e93\u4e50\u89c2\u9501\uff1b<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"font-size: 16px;visibility: visible;\">2. \u57fa\u4e8eRedis\u7684\u5206\u5e03\u5f0f\u9501\uff1b<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"font-size: 16px;visibility: visible;\">3. \u57fa\u4e8eZooKeeper\u7684\u5206\u5e03\u5f0f\u9501\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"font-size: 16px;visibility: visible;\">\u672c\u7bc7\u5c06\u4ecb\u7ecd\u7b2c\u4e8c\u79cd\u65b9\u5f0f\uff0c\u57fa\u4e8eRedis\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><\/span><\/p>\n<section data-class=\"_mbEditor\" data-id=\"132148\" style=\"visibility: visible;\">\n<section data-tools-id=\"46476\" style=\"visibility: visible;\">\n<section style=\"font-family: Arial;border-width: 0px 0px 2px;border-style: none none solid;color: rgb(49, 147, 105);border-color: rgb(239, 112, 96);visibility: visible;\">\n<p placeholder=\"1\" style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;font-size: 15px;border-radius: 80% 100% 90% 20%;color: rgb(255, 255, 255);float: left;line-height: 20px;margin-right: 8px;padding: 4px 10px;background-color: rgb(239, 112, 96);visibility: visible;\"><span>2<\/span><\/p>\n<p style=\"unicode-bidi: embed;margin: 1.12em 0;display: inline-block;font-weight: bold;font-size: 16px;line-height: 28px;color: rgb(239, 112, 96);min-height: 32px;visibility: visible;\"><span>\u53ef\u9760\u6027<\/span><\/p>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"font-size: 16px;visibility: visible;\">\u9996\u5148\uff0c\u4e3a\u4e86\u786e\u4fdd\u5206\u5e03\u5f0f\u9501\u53ef\u7528\uff0c\u6211\u4eec\u81f3\u5c11\u8981\u786e\u4fdd\u9501\u7684\u5b9e\u73b0\u540c\u65f6\u6ee1\u8db3\u4ee5\u4e0b\u56db\u4e2a\u6761\u4ef6\uff1a<\/span><\/span><\/p>\n<ul class=\"list-paddingleft-2\" style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;margin-left: 40px;list-style-type: disc;visibility: visible;\">\n<li style=\"display: list-item;visibility: visible;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;visibility: visible;\"><span><strong style=\"font-weight: bolder;visibility: visible;\"><span style=\"font-size: 16px;visibility: visible;\">\u4e92\u65a5\u6027<\/span><\/strong><span style=\"font-size: 16px;visibility: visible;\">\u3002\u5728\u4efb\u610f\u65f6\u523b\uff0c\u53ea\u6709\u4e00\u4e2a\u5ba2\u6237\u7aef\u80fd\u6301\u6709\u9501\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;visibility: visible;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;visibility: visible;\"><span><strong style=\"font-weight: bolder;visibility: visible;\"><span style=\"font-size: 16px;visibility: visible;\">\u4e0d\u4f1a\u53d1\u751f\u6b7b\u9501<\/span><\/strong><span style=\"font-size: 16px;visibility: visible;\">\u3002\u5373\u4f7f\u6709\u4e00\u4e2a\u5ba2\u6237\u7aef\u5728\u6301\u6709\u9501\u7684\u671f\u95f4\u5d29\u6e83\u800c\u6ca1\u6709\u4e3b\u52a8\u89e3\u9501\uff0c\u4e5f\u80fd\u4fdd\u8bc1\u540e\u7eed\u5176\u4ed6\u5ba2\u6237\u7aef\u80fd\u52a0\u9501\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;visibility: visible;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;visibility: visible;\"><span><strong style=\"font-weight: bolder;visibility: visible;\"><span style=\"font-size: 16px;visibility: visible;\">\u5177\u6709\u5bb9\u9519\u6027<\/span><\/strong><span style=\"font-size: 16px;visibility: visible;\">\u3002\u53ea\u8981\u5927\u90e8\u5206\u7684Redis\u8282\u70b9\u6b63\u5e38\u8fd0\u884c\uff0c\u5ba2\u6237\u7aef\u5c31\u53ef\u4ee5\u52a0\u9501\u548c\u89e3\u9501\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;visibility: visible;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;visibility: visible;\"><span><strong style=\"font-weight: bolder;visibility: visible;\"><span style=\"font-size: 16px;visibility: visible;\">\u89e3\u94c3\u8fd8\u987b\u7cfb\u94c3\u4eba<\/span><\/strong><span style=\"font-size: 16px;visibility: visible;\">\u3002\u52a0\u9501\u548c\u89e3\u9501\u5fc5\u987b\u662f\u540c\u4e00\u4e2a\u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u81ea\u5df1\u4e0d\u80fd\u628a\u522b\u4eba\u52a0\u7684\u9501\u7ed9\u89e3\u4e86\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<\/ul>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><\/span><\/p>\n<section data-class=\"_mbEditor\" data-id=\"132148\" style=\"visibility: visible;\">\n<section data-tools-id=\"46476\" style=\"visibility: visible;\">\n<section style=\"font-family: Arial;border-width: 0px 0px 2px;border-style: none none solid;color: rgb(49, 147, 105);border-color: rgb(239, 112, 96);visibility: visible;\">\n<p placeholder=\"1\" style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;font-size: 15px;border-radius: 80% 100% 90% 20%;color: rgb(255, 255, 255);float: left;line-height: 20px;margin-right: 8px;padding: 4px 10px;background-color: rgb(239, 112, 96);visibility: visible;\"><span>3<\/span><\/p>\n<p style=\"unicode-bidi: embed;margin: 1.12em 0;display: inline-block;font-weight: bold;font-size: 16px;line-height: 28px;color: rgb(239, 112, 96);min-height: 32px;visibility: visible;\"><span>\u4ee3\u7801\u5b9e\u73b0<\/span><\/p>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;visibility: visible;\"><span><span style=\"color: rgb(255, 76, 0);visibility: visible;\"><strong style=\"font-weight: bolder;visibility: visible;\"><span style=\"color: rgb(255, 76, 0);font-size: 16px;visibility: visible;\">\u7ec4\u4ef6\u4f9d\u8d56<\/span><\/strong><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u9996\u5148\u6211\u4eec\u8981\u901a\u8fc7Maven\u5f15\u5165Jedis\u5f00\u6e90\u7ec4\u4ef6\uff0c\u5728pom.xml\u6587\u4ef6\u52a0\u5165\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__3\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 79px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 66px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 66px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__4\">dependency<\/span>&gt;<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 60px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__5\">groupId<\/span>&gt;<\/span>redis.clients<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 66px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;\/<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__6\">groupId<\/span>&gt;<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 79px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 66px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 66px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__7\">artifactId<\/span>&gt;<\/span>jedis<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 86px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;\/<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 66px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 66px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__8\">artifactId<\/span>&gt;<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 60px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__9\">version<\/span>&gt;<\/span>2.9.0<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 66px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;\/<span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__10\">version<\/span>&gt;<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 86px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">&lt;\/<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 66px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 66px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__11\">dependency<\/span>&gt;<\/span><\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"color: rgb(255, 76, 0);\"><strong style=\"font-weight: bolder;\"><span style=\"color: rgb(255, 76, 0);font-size: 16px;\">\u52a0\u9501\u4ee3\u7801<\/span><\/strong><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 16px;\">\u6b63\u786e\u59ff\u52bf<\/span><\/strong><span style=\"font-size: 16px;\"><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">Talk is cheap, show me the code\u3002\u5148\u5c55\u793a\u4ee3\u7801\uff0c\u518d\u5e26\u5927\u5bb6\u6162\u6162\u89e3\u91ca\u4e3a\u4ec0\u4e48\u8fd9\u6837\u5b9e\u73b0\uff1a<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__12\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__13\">public<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 106px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\"><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__14\">class<\/span><span style=\"font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 59px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">RedisTool<\/span><\/span>{<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__15\">private<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__16\">static<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__17\">final<\/span>String LOCK_SUCCESS = <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">&quot;OK&quot;<\/span>;<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__18\">private<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__19\">static<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__20\">final<\/span>String SET_IF_NOT_EXIST = <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 27px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">&quot;NX&quot;<\/span>;<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__21\">private<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__22\">static<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__23\">final<\/span>String SET_WITH_EXPIRE_TIME = <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">&quot;PX&quot;<\/span>;<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 213px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 213px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__24\">\/*** \u5c1d\u8bd5\u83b7\u53d6\u5206\u5e03\u5f0f\u9501* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__25\">@param<\/span>jedis Redis\u5ba2\u6237\u7aef* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__26\">@param<\/span>lockKey \u9501* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__27\">@param<\/span>requestId \u8bf7\u6c42\u6807\u8bc6* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__28\">@param<\/span>expireTime \u8d85\u671f\u65f6\u95f4* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__29\">@return<\/span>\u662f\u5426\u83b7\u53d6\u6210\u529f*\/<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 706px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\"><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__30\">public<\/span><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__31\">static<\/span><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__32\">boolean<\/span><span style=\"font-size: 12px;color: rgb(166, 226, 46);background: rgba(0, 0, 0, 0);display: inline;width: 139px;text-decoration: none solid rgb(166, 226, 46);font-weight: 400;font-style: normal;\">tryGetDistributedLock<\/span><span style=\"font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 416px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">(Jedis jedis, String lockKey, String requestId, <span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 19px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 19px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__33\">int<\/span>expireTime)<\/span><\/span>{String result = jedis.set(lockKey, requestId, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, expireTime);<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__34\">if<\/span>(LOCK_SUCCESS.equals(result)) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__35\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 26px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__36\">true<\/span>;}<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__37\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__38\">false<\/span>;}}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u53ef\u4ee5\u770b\u5230\uff0c\u6211\u4eec\u52a0\u9501\u5c31\u4e00\u884c\u4ee3\u7801\uff1a<\/span><span style=\"font-size: 16px;color: rgb(255, 76, 0);background-color: rgb(214, 214, 214);font-size: 16px;\" data-style=\"color: rgb(255, 76, 0); background-color: rgb(214, 214, 214); font-size: 16px;\" class=\"js_darkmode__39\">jedis.set(String key, String value, String nxxx, String expx, int time)<\/span><span style=\"font-size: 16px;\">\uff0c\u8fd9\u4e2aset()\u65b9\u6cd5\u4e00\u5171\u6709\u4e94\u4e2a\u5f62\u53c2\uff1a<\/span><\/span><\/p>\n<ul class=\"list-paddingleft-2\" style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;margin-left: 40px;list-style-type: disc;\">\n<li style=\"display: list-item;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\"><span><span style=\"font-size: 16px;\">\u7b2c\u4e00\u4e2a\u4e3akey\uff0c\u6211\u4eec\u4f7f\u7528key\u6765\u5f53\u9501\uff0c\u56e0\u4e3akey\u662f\u552f\u4e00\u7684\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\"><span><span style=\"font-size: 16px;\">\u7b2c\u4e8c\u4e2a\u4e3avalue\uff0c\u6211\u4eec\u4f20\u7684\u662frequestId\uff0c\u5f88\u591a\u7ae5\u978b\u53ef\u80fd\u4e0d\u660e\u767d\uff0c\u6709key\u4f5c\u4e3a\u9501\u4e0d\u5c31\u591f\u4e86\u5417\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u8981\u7528\u5230value\uff1f\u539f\u56e0\u5c31\u662f\u6211\u4eec\u5728\u4e0a\u9762\u8bb2\u5230\u53ef\u9760\u6027\u65f6\uff0c\u5206\u5e03\u5f0f\u9501\u8981\u6ee1\u8db3\u7b2c\u56db\u4e2a\u6761\u4ef6\u89e3\u94c3\u8fd8\u987b\u7cfb\u94c3\u4eba\uff0c\u901a\u8fc7\u7ed9value\u8d4b\u503c\u4e3arequestId\uff0c\u6211\u4eec\u5c31\u77e5\u9053\u8fd9\u628a\u9501\u662f\u54ea\u4e2a\u8bf7\u6c42\u52a0\u7684\u4e86\uff0c\u5728\u89e3\u9501\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u6709\u4f9d\u636e\u3002requestId\u53ef\u4ee5\u4f7f\u7528UUID.randomUUID().toString()\u65b9\u6cd5\u751f\u6210\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\"><span><span style=\"font-size: 16px;\">\u7b2c\u4e09\u4e2a\u4e3anxxx\uff0c\u8fd9\u4e2a\u53c2\u6570\u6211\u4eec\u586b\u7684\u662fNX\uff0c\u610f\u601d\u662fSET IF NOT EXIST\uff0c\u5373\u5f53key\u4e0d\u5b58\u5728\u65f6\uff0c\u6211\u4eec\u8fdb\u884cset\u64cd\u4f5c\uff1b\u82e5key\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u4e0d\u505a\u4efb\u4f55\u64cd\u4f5c\uff1b<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\"><span><span style=\"font-size: 16px;\">\u7b2c\u56db\u4e2a\u4e3aexpx\uff0c\u8fd9\u4e2a\u53c2\u6570\u6211\u4eec\u4f20\u7684\u662fPX\uff0c\u610f\u601d\u662f\u6211\u4eec\u8981\u7ed9\u8fd9\u4e2akey\u52a0\u4e00\u4e2a\u8fc7\u671f\u7684\u8bbe\u7f6e\uff0c\u5177\u4f53\u65f6\u95f4\u7531\u7b2c\u4e94\u4e2a\u53c2\u6570\u51b3\u5b9a\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<li style=\"display: list-item;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\"><span><span style=\"font-size: 16px;\">\u7b2c\u4e94\u4e2a\u4e3atime\uff0c\u4e0e\u7b2c\u56db\u4e2a\u53c2\u6570\u76f8\u547c\u5e94\uff0c\u4ee3\u8868key\u7684\u8fc7\u671f\u65f6\u95f4\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;color: rgb(51, 51, 51);font-size: 15px;margin: 0;\">\n<\/li>\n<\/ul>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u603b\u7684\u6765\u8bf4\uff0c\u6267\u884c\u4e0a\u9762\u7684set()\u65b9\u6cd5\u5c31\u53ea\u4f1a\u5bfc\u81f4\u4e24\u79cd\u7ed3\u679c\uff1a<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">1. \u5f53\u524d\u6ca1\u6709\u9501\uff08key\u4e0d\u5b58\u5728\uff09\uff0c\u90a3\u4e48\u5c31\u8fdb\u884c\u52a0\u9501\u64cd\u4f5c\uff0c\u5e76\u5bf9\u9501\u8bbe\u7f6e\u4e2a\u6709\u6548\u671f\uff0c\u540c\u65f6value\u8868\u793a\u52a0\u9501\u7684\u5ba2\u6237\u7aef\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">2. \u5df2\u6709\u9501\u5b58\u5728\uff0c\u4e0d\u505a\u4efb\u4f55\u64cd\u4f5c\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u5fc3\u7ec6\u7684\u7ae5\u978b\u5c31\u4f1a\u53d1\u73b0\u4e86\uff0c\u6211\u4eec\u7684\u52a0\u9501\u4ee3\u7801\u6ee1\u8db3\u6211\u4eec\u53ef\u9760\u6027\u91cc\u63cf\u8ff0\u7684\u4e09\u4e2a\u6761\u4ef6\u3002\u9996\u5148\uff0cset()\u52a0\u5165\u4e86NX\u53c2\u6570\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u5982\u679c\u5df2\u6709key\u5b58\u5728\uff0c\u5219\u51fd\u6570\u4e0d\u4f1a\u8c03\u7528\u6210\u529f\uff0c\u4e5f\u5c31\u662f\u53ea\u6709\u4e00\u4e2a\u5ba2\u6237\u7aef\u80fd\u6301\u6709\u9501\uff0c\u6ee1\u8db3\u4e92\u65a5\u6027\u3002\u5176\u6b21\uff0c\u7531\u4e8e\u6211\u4eec\u5bf9\u9501\u8bbe\u7f6e\u4e86\u8fc7\u671f\u65f6\u95f4\uff0c\u5373\u4f7f\u9501\u7684\u6301\u6709\u8005\u540e\u7eed\u53d1\u751f\u5d29\u6e83\u800c\u6ca1\u6709\u89e3\u9501\uff0c\u9501\u4e5f\u4f1a\u56e0\u4e3a\u5230\u4e86\u8fc7\u671f\u65f6\u95f4\u800c\u81ea\u52a8\u89e3\u9501\uff08\u5373key\u88ab\u5220\u9664\uff09\uff0c\u4e0d\u4f1a\u53d1\u751f\u6b7b\u9501\u3002\u6700\u540e\uff0c\u56e0\u4e3a\u6211\u4eec\u5c06value\u8d4b\u503c\u4e3arequestId\uff0c\u4ee3\u8868\u52a0\u9501\u7684\u5ba2\u6237\u7aef\u8bf7\u6c42\u6807\u8bc6\uff0c\u90a3\u4e48\u5728\u5ba2\u6237\u7aef\u5728\u89e3\u9501\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u8fdb\u884c\u6821\u9a8c\u662f\u5426\u662f\u540c\u4e00\u4e2a\u5ba2\u6237\u7aef\u3002\u7531\u4e8e\u6211\u4eec\u53ea\u8003\u8651Redis\u5355\u673a\u90e8\u7f72\u7684\u573a\u666f\uff0c\u6240\u4ee5\u5bb9\u9519\u6027\u6211\u4eec\u6682\u4e0d\u8003\u8651\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 16px;\">\u9519\u8bef\u793a\u4f8b1<\/span><\/strong><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u6bd4\u8f83\u5e38\u89c1\u7684\u9519\u8bef\u793a\u4f8b\u5c31\u662f\u4f7f\u7528jedis.setnx()\u548cjedis.expire()\u7ec4\u5408\u5b9e\u73b0\u52a0\u9501\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__40\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 633px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\"><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__41\">public<\/span><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__42\">static<\/span><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 27px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 27px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__43\">void<\/span><span style=\"font-size: 12px;color: rgb(166, 226, 46);background: rgba(0, 0, 0, 0);display: inline;width: 86px;text-decoration: none solid rgb(166, 226, 46);font-weight: 400;font-style: normal;\">wrongGetLock1<\/span><span style=\"font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 416px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">(Jedis jedis, String lockKey, String requestId, <span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 19px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 19px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__44\">int<\/span>expireTime)<\/span><\/span>{Long result = jedis.setnx(lockKey, requestId);<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__45\">if<\/span>(result == <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 7px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">1<\/span>) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 331px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 331px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__46\">\/\/ \u82e5\u5728\u8fd9\u91cc\u7a0b\u5e8f\u7a81\u7136\u5d29\u6e83\uff0c\u5219\u65e0\u6cd5\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\uff0c\u5c06\u53d1\u751f\u6b7b\u9501<\/span>jedis.expire(lockKey, expireTime);}}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">setnx()\u65b9\u6cd5\u4f5c\u7528\u5c31\u662f<\/span><span style=\"font-size: 16px;color: rgb(255, 76, 0);background-color: rgb(214, 214, 214);\" data-style=\"font-size: 16px; color: rgb(255, 76, 0); background-color: rgb(214, 214, 214);\" class=\"js_darkmode__47\">SET IF NOT EXIST<\/span><span style=\"font-size: 16px;\">\uff0cexpire()\u65b9\u6cd5\u5c31\u662f\u7ed9\u9501\u52a0\u4e00\u4e2a\u8fc7\u671f\u65f6\u95f4\u3002\u4e4d\u4e00\u770b\u597d\u50cf\u548c\u524d\u9762\u7684set()\u65b9\u6cd5\u7ed3\u679c\u4e00\u6837\uff0c\u7136\u800c\u7531\u4e8e\u8fd9\u662f\u4e24\u6761Redis\u547d\u4ee4\uff0c\u4e0d\u5177\u6709\u539f\u5b50\u6027\uff0c\u5982\u679c\u7a0b\u5e8f\u5728\u6267\u884c\u5b8csetnx()\u4e4b\u540e\u7a81\u7136\u5d29\u6e83\uff0c\u5bfc\u81f4\u9501\u6ca1\u6709\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\u3002\u90a3\u4e48\u5c06\u4f1a\u53d1\u751f\u6b7b\u9501\u3002\u7f51\u4e0a\u4e4b\u6240\u4ee5\u6709\u4eba\u8fd9\u6837\u5b9e\u73b0\uff0c\u662f\u56e0\u4e3a\u4f4e\u7248\u672c\u7684jedis\u5e76\u4e0d\u652f\u6301\u591a\u53c2\u6570\u7684set()\u65b9\u6cd5\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 16px;\">\u9519\u8bef\u793a\u4f8b2<\/span><\/strong><span style=\"font-size: 16px;\"><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u8fd9\u4e00\u79cd\u9519\u8bef\u793a\u4f8b\u5c31\u6bd4\u8f83\u96be\u4ee5\u53d1\u73b0\u95ee\u9898\uff0c\u800c\u4e14\u5b9e\u73b0\u4e5f\u6bd4\u8f83\u590d\u6742\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u5b9e\u73b0\u601d\u8def\uff1a\u4f7f\u7528<\/span><span style=\"font-size: 16px;color: rgb(255, 76, 0);background-color: rgb(214, 214, 214);\" data-style=\"font-size: 16px; color: rgb(255, 76, 0); background-color: rgb(214, 214, 214);\" class=\"js_darkmode__48\">jedis.setnx()<\/span><span style=\"font-size: 16px;\">\u547d\u4ee4\u5b9e\u73b0\u52a0\u9501\uff0c\u5176\u4e2dkey\u662f\u9501\uff0cvalue\u662f\u9501\u7684\u8fc7\u671f\u65f6\u95f4\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u6267\u884c\u8fc7\u7a0b\uff1a<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">1. \u901a\u8fc7setnx()\u65b9\u6cd5\u5c1d\u8bd5\u52a0\u9501\uff0c\u5982\u679c\u5f53\u524d\u9501\u4e0d\u5b58\u5728\uff0c\u8fd4\u56de\u52a0\u9501\u6210\u529f\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">2. \u5982\u679c\u9501\u5df2\u7ecf\u5b58\u5728\u5219\u83b7\u53d6\u9501\u7684\u8fc7\u671f\u65f6\u95f4\uff0c\u548c\u5f53\u524d\u65f6\u95f4\u6bd4\u8f83\uff0c\u5982\u679c\u9501\u5df2\u7ecf\u8fc7\u671f\uff0c\u5219\u8bbe\u7f6e\u65b0\u7684\u8fc7\u671f\u65f6\u95f4\uff0c\u8fd4\u56de\u52a0\u9501\u6210\u529f\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__49\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__50\">public<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__51\">static<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">boolean<\/span>wrongGetLock2(Jedis jedis, <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">String<\/span>lockKey, int expireTime) {long expires = System.currentTimeMillis() + expireTime;<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">String<\/span>expiresStr = <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">String<\/span>.valueOf(expires);<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 200px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 200px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__52\">\/\/ \u5982\u679c\u5f53\u524d\u9501\u4e0d\u5b58\u5728\uff0c\u8fd4\u56de\u52a0\u9501\u6210\u529f<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__53\">if<\/span>(jedis.setnx(lockKey, expiresStr) == <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 7px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">1<\/span>) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__54\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">true<\/span>;}<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 188px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 188px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__55\">\/\/ \u5982\u679c\u9501\u5b58\u5728\uff0c\u83b7\u53d6\u9501\u7684\u8fc7\u671f\u65f6\u95f4<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">String<\/span>currentValueStr = jedis.get(lockKey);<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__56\">if<\/span>(currentValueStr != <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">null<\/span>&amp;&amp; Long.parseLong(currentValueStr) &lt; System.currentTimeMillis()) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 355px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 355px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__57\">\/\/ \u9501\u5df2\u8fc7\u671f\uff0c\u83b7\u53d6\u4e0a\u4e00\u4e2a\u9501\u7684\u8fc7\u671f\u65f6\u95f4\uff0c\u5e76\u8bbe\u7f6e\u73b0\u5728\u9501\u7684\u8fc7\u671f\u65f6\u95f4<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">String<\/span>oldValueStr = jedis.getSet(lockKey, expiresStr);<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__58\">if<\/span>(oldValueStr != <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">null<\/span>&amp;&amp; oldValueStr.equals(currentValueStr)) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 440px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 440px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__59\">\/\/ \u8003\u8651\u591a\u7ebf\u7a0b\u5e76\u53d1\u7684\u60c5\u51b5\uff0c\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u7684\u8bbe\u7f6e\u503c\u548c\u5f53\u524d\u503c\u76f8\u540c\uff0c\u5b83\u624d\u6709\u6743\u5229\u52a0\u9501<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__60\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">true<\/span>;}}<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 176px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 176px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__61\">\/\/ \u5176\u4ed6\u60c5\u51b5\uff0c\u4e00\u5f8b\u8fd4\u56de\u52a0\u9501\u5931\u8d25<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__62\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">false<\/span>;}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;color: rgb(217, 33, 66);\">\u90a3\u4e48\u8fd9\u6bb5\u4ee3\u7801\u95ee\u9898\u5728\u54ea\u91cc\uff1f<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">1. \u7531\u4e8e\u662f\u5ba2\u6237\u7aef\u81ea\u5df1\u751f\u6210\u8fc7\u671f\u65f6\u95f4\uff0c\u6240\u4ee5\u9700\u8981\u5f3a\u5236\u8981\u6c42\u5206\u5e03\u5f0f\u4e0b\u6bcf\u4e2a\u5ba2\u6237\u7aef\u7684\u65f6\u95f4\u5fc5\u987b\u540c\u6b65\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">2. \u5f53\u9501\u8fc7\u671f\u7684\u65f6\u5019\uff0c\u5982\u679c\u591a\u4e2a\u5ba2\u6237\u7aef\u540c\u65f6\u6267\u884c<\/span><span style=\"color: rgb(255, 76, 0);font-size: 16px;background-color: rgb(214, 214, 214);\" data-style=\"color: rgb(255, 76, 0); font-size: 16px; background-color: rgb(214, 214, 214);\" class=\"js_darkmode__63\">jedis.getSet()<\/span><span style=\"font-size: 16px;\">\u65b9\u6cd5\uff0c\u90a3\u4e48\u867d\u7136\u6700\u7ec8\u53ea\u6709\u4e00\u4e2a\u5ba2\u6237\u7aef\u53ef\u4ee5\u52a0\u9501\uff0c\u4f46\u662f\u8fd9\u4e2a\u5ba2\u6237\u7aef\u7684\u9501\u7684\u8fc7\u671f\u65f6\u95f4\u53ef\u80fd\u88ab\u5176\u4ed6\u5ba2\u6237\u7aef\u8986\u76d6\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">3. \u9501\u4e0d\u5177\u5907\u62e5\u6709\u8005\u6807\u8bc6\uff0c\u5373\u4efb\u4f55\u5ba2\u6237\u7aef\u90fd\u53ef\u4ee5\u89e3\u9501\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"color: rgb(255, 76, 0);\"><strong style=\"font-weight: bolder;\"><span style=\"color: rgb(255, 76, 0);font-size: 16px;\">\u89e3\u9501\u4ee3\u7801<\/span><\/strong><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 16px;\">\u6b63\u786e\u59ff\u52bf<\/span><\/strong><span style=\"font-size: 16px;\"><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u8fd8\u662f\u5148\u5c55\u793a\u4ee3\u7801\uff0c\u518d\u5e26\u5927\u5bb6\u6162\u6162\u89e3\u91ca\u4e3a\u4ec0\u4e48\u8fd9\u6837\u5b9e\u73b0\uff1a<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__64\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__65\">public<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 106px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\"><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__66\">class<\/span><span style=\"font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 59px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">RedisTool<\/span><\/span>{<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__67\">private<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__68\">static<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__69\">final<\/span>Long RELEASE_SUCCESS = <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(174, 129, 255);background: rgba(0, 0, 0, 0);display: inline;width: 7px;text-decoration: none solid rgb(174, 129, 255);font-weight: 400;font-style: normal;\">1<\/span>L;<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 206px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 206px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__70\">\/*** \u91ca\u653e\u5206\u5e03\u5f0f\u9501* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__71\">@param<\/span>jedis Redis\u5ba2\u6237\u7aef* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__72\">@param<\/span>lockKey \u9501* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__73\">@param<\/span>requestId \u8bf7\u6c42\u6807\u8bc6* <span style=\"font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 46px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 46px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__74\">@return<\/span>\u662f\u5426\u91ca\u653e\u6210\u529f*\/<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__75\">public<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__76\">static<\/span>boolean releaseDistributedLock(Jedis jedis, String lockKey, String requestId) {String script = <span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(230, 219, 116);background: rgba(0, 0, 0, 0);display: inline;width: 653px;text-decoration: none solid rgb(230, 219, 116);font-weight: 400;font-style: normal;\">&quot;if redis.call(&#39;get&#39;, KEYS[1]) == ARGV[1] then return redis.call(&#39;del&#39;, KEYS[1]) else return 0 end&quot;<\/span>;Object result = jedis.<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 26px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__77\">eval<\/span>(script, Collections.singletonList(lockKey), Collections.singletonList(requestId));<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__78\">if<\/span>(RELEASE_SUCCESS.equals(result)) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__79\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 26px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 26px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__80\">true<\/span>;}<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__81\">return<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 33px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 33px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__82\">false<\/span>;}}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u53ef\u4ee5\u770b\u5230\uff0c\u6211\u4eec\u89e3\u9501\u53ea\u9700\u8981\u4e24\u884c\u4ee3\u7801\u5c31\u641e\u5b9a\u4e86\uff01\u7b2c\u4e00\u884c\u4ee3\u7801\uff0c\u6211\u4eec\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684Lua\u811a\u672c\u4ee3\u7801\uff0c\u4e0a\u4e00\u6b21\u89c1\u5230\u8fd9\u4e2a\u7f16\u7a0b\u8bed\u8a00\u8fd8\u662f\u5728\u300a\u9ed1\u5ba2\u4e0e\u753b\u5bb6\u300b\u91cc\uff0c\u6ca1\u60f3\u5230\u8fd9\u6b21\u5c45\u7136\u7528\u4e0a\u4e86\u3002\u7b2c\u4e8c\u884c\u4ee3\u7801\uff0c\u6211\u4eec\u5c06Lua\u4ee3\u7801\u4f20\u5230jedis.eval()\u65b9\u6cd5\u91cc\uff0c\u5e76\u4f7f\u53c2\u6570KEYS[1]\u8d4b\u503c\u4e3alockKey\uff0cARGV[1]\u8d4b\u503c\u4e3arequestId\u3002eval()\u65b9\u6cd5\u662f\u5c06Lua\u4ee3\u7801\u4ea4\u7ed9Redis\u670d\u52a1\u7aef\u6267\u884c\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u90a3\u4e48\u8fd9\u6bb5Lua\u4ee3\u7801\u7684\u529f\u80fd\u662f\u4ec0\u4e48\u5462\uff1f\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u9996\u5148\u83b7\u53d6\u9501\u5bf9\u5e94\u7684value\u503c\uff0c\u68c0\u67e5\u662f\u5426\u4e0erequestId\u76f8\u7b49\uff0c\u5982\u679c\u76f8\u7b49\u5219\u5220\u9664\u9501\uff08\u89e3\u9501\uff09\u3002\u90a3\u4e48\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528Lua\u8bed\u8a00\u6765\u5b9e\u73b0\u5462\uff1f\u56e0\u4e3a\u8981\u786e\u4fdd\u4e0a\u8ff0\u64cd\u4f5c\u662f\u539f\u5b50\u6027\u7684\u3002\u5173\u4e8e\u975e\u539f\u5b50\u6027\u4f1a\u5e26\u6765\u4ec0\u4e48\u95ee\u9898\uff0c\u53ef\u4ee5\u9605\u8bfb\u3010\u89e3\u9501\u4ee3\u7801-\u9519\u8bef\u793a\u4f8b2\u3011 \u3002\u90a3\u4e48\u4e3a\u4ec0\u4e48\u6267\u884ceval()\u65b9\u6cd5\u53ef\u4ee5\u786e\u4fdd\u539f\u5b50\u6027\uff0c\u6e90\u4e8eRedis\u7684\u7279\u6027\uff0c\u4e0b\u9762\u662f\u5b98\u7f51\u5bf9eval\u547d\u4ee4\u7684\u90e8\u5206\u89e3\u91ca\uff1a<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u5728eval\u547d\u4ee4\u6267\u884cLua\u4ee3\u7801\u7684\u65f6\u5019\uff0cLua\u4ee3\u7801\u5c06\u88ab\u5f53\u6210\u4e00\u4e2a\u547d\u4ee4\u53bb\u6267\u884c\uff0c\u5e76\u4e14\u76f4\u5230eval\u547d\u4ee4\u6267\u884c\u5b8c\u6210\uff0cRedis\u624d\u4f1a\u6267\u884c\u5176\u4ed6\u547d\u4ee4\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 16px;\">\u9519\u8bef\u793a\u4f8b1<\/span><\/strong><span style=\"font-size: 16px;\"><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u6700\u5e38\u89c1\u7684\u89e3\u9501\u4ee3\u7801\u5c31\u662f\u76f4\u63a5\u4f7f\u7528<strong style=\"font-weight: bolder;\">jedis.del()<\/strong>\u65b9\u6cd5\u5220\u9664\u9501\uff0c\u8fd9\u79cd\u4e0d\u5148\u5224\u65ad\u9501\u7684\u62e5\u6709\u8005\u800c\u76f4\u63a5\u89e3\u9501\u7684\u65b9\u5f0f\uff0c\u4f1a\u5bfc\u81f4\u4efb\u4f55\u5ba2\u6237\u7aef\u90fd\u53ef\u4ee5\u968f\u65f6\u8fdb\u884c\u89e3\u9501\uff0c\u5373\u4f7f\u8fd9\u628a\u9501\u4e0d\u662f\u5b83\u7684\u3002<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__83\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 435px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__84\">public<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__85\">static<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 27px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 27px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__86\">void<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(166, 226, 46);background: rgba(0, 0, 0, 0);display: inline;width: 112px;text-decoration: none solid rgb(166, 226, 46);font-weight: 400;font-style: normal;\">wrongReleaseLock1<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 192px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">(Jedis jedis, String lockKey)<\/span><\/span>{jedis.del(lockKey);}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 16px;\">\u9519\u8bef\u793a\u4f8b2<\/span><\/strong><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u8fd9\u79cd\u89e3\u9501\u4ee3\u7801\u4e4d\u4e00\u770b\u4e5f\u662f\u6ca1\u95ee\u9898\uff0c\u751a\u81f3\u6211\u4e4b\u524d\u4e5f\u5dee\u70b9\u8fd9\u6837\u5b9e\u73b0\uff0c\u4e0e\u6b63\u786e\u59ff\u52bf\u5dee\u4e0d\u591a\uff0c\u552f\u4e00\u533a\u522b\u7684\u662f\u5206\u6210\u4e24\u6761\u547d\u4ee4\u53bb\u6267\u884c\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/span><\/p>\n<section data-mpa-preserve-tpl-color=\"t\" data-mpa-template=\"t\" mpa-preserve=\"t\" mpa-from-tpl=\"t\">\n<pre style=\"display: block;unicode-bidi: embed;font-family: monospace;white-space: pre;margin: 0;padding: 0;border-radius: none;background: none;\"><code style=\"font-family: monospace;border-radius: 4px;font-size: 0.85em;margin: 0px 0.15em;background: rgb(35, 36, 31);color: rgb(248, 248, 242);display: block;padding: 5.95px;overflow-x: auto;white-space: nowrap;\" data-style=\"border-radius: 4px; font-size: 0.85em; margin: 0px 0.15em; background: rgb(35, 36, 31); color: rgb(248, 248, 242); display: block; padding: 5.95px; overflow-x: auto; white-space: nowrap;\" class=\"js_darkmode__87\"><span style=\"font-size: 12px;font-family: CourierNewPS-ItalicMT;\"><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 554px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\"><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 39px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 39px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__88\">public<\/span><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__89\">static<\/span><span style=\"font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 27px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 27px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__90\">void<\/span><span style=\"font-size: 12px;color: rgb(166, 226, 46);background: rgba(0, 0, 0, 0);display: inline;width: 112px;text-decoration: none solid rgb(166, 226, 46);font-weight: 400;font-style: normal;\">wrongReleaseLock2<\/span>(<span style=\"font-size: 12px;color: rgb(248, 248, 242);background: rgba(0, 0, 0, 0);display: inline;width: 297px;text-decoration: none solid rgb(248, 248, 242);font-weight: 400;font-style: normal;\">Jedis jedis, String lockKey, String requestId<\/span>) <\/span>{<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 212px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 212px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__91\">\/\/ \u5224\u65ad\u52a0\u9501\u4e0e\u89e3\u9501\u662f\u4e0d\u662f\u540c\u4e00\u4e2a\u5ba2\u6237\u7aef<\/span><span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 13px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 13px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__92\">if<\/span>(requestId.<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 40px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 40px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__93\">equals<\/span>(jedis.<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(249, 38, 114);background: rgba(0, 0, 0, 0);display: inline;width: 20px;text-decoration: none solid rgb(249, 38, 114);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(249, 38, 114); background: rgba(0, 0, 0, 0); display: inline; width: 20px; text-decoration: none solid rgb(249, 38, 114); font-weight: 400; font-style: normal;\" class=\"js_darkmode__94\">get<\/span>(lockKey))) {<span style=\"font-family: CourierNewPS-ItalicMT;font-size: 12px;color: rgb(117, 113, 94);background: rgba(0, 0, 0, 0);display: inline;width: 307px;text-decoration: none solid rgb(117, 113, 94);font-weight: 400;font-style: normal;\" data-style=\"font-family: CourierNewPS-ItalicMT; font-size: 12px; color: rgb(117, 113, 94); background: rgba(0, 0, 0, 0); display: inline; width: 307px; text-decoration: none solid rgb(117, 113, 94); font-weight: 400; font-style: normal;\" class=\"js_darkmode__95\">\/\/ \u82e5\u5728\u6b64\u65f6\uff0c\u8fd9\u628a\u9501\u7a81\u7136\u4e0d\u662f\u8fd9\u4e2a\u5ba2\u6237\u7aef\u7684\uff0c\u5219\u4f1a\u8bef\u89e3\u9501<\/span>jedis.del(lockKey);}}<\/span><\/code><\/pre>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><span style=\"font-size: 16px;\">\u5982\u4ee3\u7801\u6ce8\u91ca\uff0c\u95ee\u9898\u5728\u4e8e\u5982\u679c\u8c03\u7528jedis.del()\u65b9\u6cd5\u7684\u65f6\u5019\uff0c\u8fd9\u628a\u9501\u5df2\u7ecf\u4e0d\u5c5e\u4e8e\u5f53\u524d\u5ba2\u6237\u7aef\u7684\u65f6\u5019\u4f1a\u89e3\u9664\u4ed6\u4eba\u52a0\u7684\u9501\u3002\u90a3\u4e48\u662f\u5426\u771f\u7684\u6709\u8fd9\u79cd\u573a\u666f\uff1f\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0c\u6bd4\u5982\u5ba2\u6237\u7aefA\u52a0\u9501\uff0c\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\u5ba2\u6237\u7aefA\u89e3\u9501\uff0c\u5728\u6267\u884cjedis.del()\u4e4b\u524d\uff0c\u9501\u7a81\u7136\u8fc7\u671f\u4e86\uff0c\u6b64\u65f6\u5ba2\u6237\u7aefB\u5c1d\u8bd5\u52a0\u9501\u6210\u529f\uff0c\u7136\u540e\u5ba2\u6237\u7aefA\u518d\u6267\u884cdel()\u65b9\u6cd5\uff0c\u5219\u5c06\u5ba2\u6237\u7aefB\u7684\u9501\u7ed9\u89e3\u9664\u4e86\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\"><span><\/span><\/p>\n<section data-class=\"_mbEditor\" data-id=\"132148\">\n<section data-tools-id=\"46476\" style=\"\">\n<section style=\"font-family: Arial;border-width: 0px 0px 2px;border-style: none none solid;color: rgb(49, 147, 105);border-color: rgb(239, 112, 96);\">\n<p placeholder=\"1\" style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;font-size: 15px;border-radius: 80% 100% 90% 20%;color: rgb(255, 255, 255);float: left;line-height: 20px;margin-right: 8px;padding: 4px 10px;background-color: rgb(239, 112, 96);\"><span>4<\/span><\/p>\n<p style=\"unicode-bidi: embed;margin: 1.12em 0;display: inline-block;font-weight: bold;font-size: 16px;line-height: 28px;color: rgb(239, 112, 96);min-height: 32px;\"><span>\u603b\u7ed3<\/span><\/p>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;text-align: left;\"><span><span style=\"font-size: 16px;\">\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Java\u4ee3\u7801\u6b63\u786e\u5b9e\u73b0Redis\u5206\u5e03\u5f0f\u9501\uff0c\u5bf9\u4e8e\u52a0\u9501\u548c\u89e3\u9501\u4e5f\u5206\u522b\u7ed9\u51fa\u4e86\u4e24\u4e2a\u6bd4\u8f83\u7ecf\u5178\u7684\u9519\u8bef\u793a\u4f8b\u3002\u5176\u5b9e\u60f3\u8981\u901a\u8fc7Redis\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u5e76\u4e0d\u96be\uff0c\u53ea\u8981\u4fdd\u8bc1\u80fd\u6ee1\u8db3\u53ef\u9760\u6027\u91cc\u7684\u56db\u4e2a\u6761\u4ef6\u3002\u4e92\u8054\u7f51\u867d\u7136\u7ed9\u6211\u4eec\u5e26\u6765\u4e86\u65b9\u4fbf\uff0c\u53ea\u8981\u6709\u95ee\u9898\u5c31\u53ef\u4ee5google\uff0c\u7136\u800c\u7f51\u4e0a\u7684\u7b54\u6848\u4e00\u5b9a\u662f\u5bf9\u7684\u5417\uff1f\u5176\u5b9e\u4e0d\u7136\uff0c\u6240\u4ee5\u6211\u4eec\u66f4\u5e94\u8be5\u65f6\u523b\u4fdd\u6301\u7740\u8d28\u7591\u7cbe\u795e\uff0c\u591a\u60f3\u591a\u9a8c\u8bc1\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;text-align: left;\"><span><span style=\"font-size: 16px;\">\u5982\u679c\u4f60\u7684\u9879\u76ee\u4e2dRedis\u662f\u591a\u673a\u90e8\u7f72\u7684\uff0c\u90a3\u4e48\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528Redisson\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\uff0c\u8fd9\u662fRedis\u5b98\u65b9\u63d0\u4f9b\u7684Java\u7ec4\u4ef6\uff0c\u94fe\u63a5\u5728\u53c2\u8003\u9605\u8bfb\u7ae0\u8282\u5df2\u7ecf\u7ed9\u51fa\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;text-align: left;\"><span><span style=\"font-size: 12px;color: rgb(136, 136, 136);\">\u53c2\u8003\u9605\u8bfb\uff1ahttps:\/\/wudashan.cn\/2017\/10\/23\/Redis-Distributed-Lock-Implement\/<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;outline: 0px;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);color: rgb(89, 89, 89);font-size: 15px;text-align: left;\" data-style=\"outline: 0px; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); color: rgb(89, 89, 89); font-size: 15px; text-align: left; font-family: -apple-system, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;\" class=\"js_darkmode__96\"><span><strong style=\"font-weight: bolder;outline: 0px;letter-spacing: 0.544px;color: rgb(255, 76, 0);\">PS\uff1a\u9632\u6b62\u627e\u4e0d\u5230\u672c\u7bc7\u6587\u7ae0\uff0c\u53ef\u4ee5\u6536\u85cf\u70b9\u8d5e\uff0c\u65b9\u4fbf\u7ffb\u9605\u67e5\u627e\u54e6\u3002<\/strong><span style=\"outline: 0px;color: rgb(0, 0, 0);font-family: PingFangSC-Light;font-size: 16px;letter-spacing: 0.544px;\" data-style=\"outline: 0px; color: rgb(0, 0, 0); font-family: PingFangSC-Light; font-size: 16px; letter-spacing: 0.544px;\" class=\"js_darkmode__97\"><\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;white-space: normal;text-align: center;\">\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;white-space: normal;text-align: left;\"><span><strong style=\"font-weight: bolder;\"><span style=\"font-size: 15px;\">\u76ee\u7684\uff1a<\/span><\/strong><span style=\"font-size: 15px;\">\u4e3a\u65b9\u4fbf\u5927\u5bb6\u6280\u672f\u4ea4\u6d41\uff0c\u63d0\u4f9b\u4e00\u4e2a\u66f4\u65b9\u4fbf\u7684\u4ea4\u6d41\u573a\u5730<span style=\"text-align: center;\">\uff0c\u4f9b\u5927\u5bb6\u4ea4\u6d41<\/span>\u5de5\u4f5c\u4e2d\u9047\u5230\u7684\u95ee\u9898\uff1b\u540c\u65f6\u5171\u540c\u5b66\u4e60\uff0c\u8fdb\u6b65\uff0c\u591a\u4e2a\u670b\u53cb\u591a\u6761\u8def\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;white-space: normal;text-align: left;\"><span><span style=\"font-size: 15px;\">\u6709\u9700\u8981\u8fdb\u7fa4\u7684\u5c0f\u4f19\u4f34\uff0c\u53ef\u4ee5\u52a0\u6211\u7684\u5fae\u4fe1\uff0c\u8bb0\u5f97\u5907\u6ce8<\/span><span style=\"color: rgb(255, 76, 0);\"><strong style=\"font-weight: bolder;\">\u300c<span style=\"font-size: 15px;\">\u8fdb\u7fa4<\/span>\u300d<\/strong><\/span><span style=\"font-size: 15px;\">\uff0c\u65b9\u4fbf\u6211\u62c9\u5927\u5bb6\u8fdb\u7fa4\u3002<\/span><\/span><\/p>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;white-space: normal;text-align: center;\">\n<section>\n<section>\n<section style=\"display: inline-block;\"><img decoding=\"async\" class=\"lazyload\"data-ratio=\"1.006785411365564\"  data-type=\"jpg\" data-w=\"1179\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214122605.jpg\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" data-ratio=\"1.006785411365564\"  data-type=\"jpg\" data-w=\"1179\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214122605.jpg\"><\/noscript><\/section>\n<\/section>\n<\/section>\n<p style=\"display: block;unicode-bidi: embed;margin: 1.12em 0;color: rgb(51, 51, 51);font-size: 15px;\">\n<\/section>\n<p style=\"display: none;\"><mp-style-type data-value=\"10000\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u7801\u8bed              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u70b9\u51fb\u201c\u7801\u8bed\u201d\uff0c\u5173\u6ce8\uff0c\u7f6e\u9876\u516c\u4f17\u53f7 \u6bcf\u65e5\u6280\u672f\u5e72\u8d27\uff0c\u7b2c\u4e00\u65f6\u95f4\u9001\u8fbe\uff01 1 \u524d\u8a00 \u5206\u5e03\u5f0f\u9501\u4e00\u822c\u6709\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff1a 1. \u6570\u636e\u5e93\u4e50\u89c2\u9501\uff1b 2.  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":4838,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[18,7,30],"tags":[],"class_list":["post-4842","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-redis","category-spring-boot","category-30"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214118195-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214122605.jpg","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214118195-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214118195.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214122605.jpg","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214118195-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214118195.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214118195.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214122605.jpg","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801214122605.jpg","id":"image1"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Redis","post_date":"2024-08-01","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":548,"next_post_id":5094,"next_post_title":"\u4e00\u5f20\u957f\u56fe\u900f\u5f7b\u7406\u89e3 SpringBoot \u542f\u52a8\u539f\u7406\uff0c\u8f7b\u677e\u641e\u5b9a\u9762\u8bd5\uff01","previous_post_id":5507,"previous_post_title":"Spring Boot\uff1a\u5c06\u6587\u4ef6\u63a8\u9001\u5230 FTP \u670d\u52a1\u5668","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=4842"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4842\/revisions"}],"predecessor-version":[{"id":6319,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4842\/revisions\/6319"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/4838"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=4842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=4842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=4842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}