{"id":171,"date":"2023-05-22T14:14:24","date_gmt":"2023-05-22T06:14:24","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=171"},"modified":"2023-05-22T14:47:45","modified_gmt":"2023-05-22T06:47:45","slug":"22fb83281a","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/java\/22fb83281a\/","title":{"rendered":"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<section class=\"mp_profile_iframe_wrp\"><\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, 'system-ui', 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: #ffffff; visibility: visible;\">\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688; visibility: visible;\">\u80cc\u666f<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; visibility: visible;\">\u5728\u590d\u6742\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u5f80\u5f80\u9700\u8981\u5bf9\u5927\u91cf\u7684\u6570\u636e\u8fdb\u884c\u552f\u4e00\u6807\u8bc6\uff0c\u6bd4\u5982\u5728\u5bf9\u4e00\u4e2a\u8ba2\u5355\u8868\u8fdb\u884c\u4e86\u5206\u5e93\u5206\u8868\u64cd\u4f5c\uff0c\u8fd9\u65f6\u5019\u6570\u636e\u5e93\u7684\u81ea\u589eID\u663e\u7136\u4e0d\u80fd\u4f5c\u4e3a\u67d0\u4e2a\u8ba2\u5355\u7684\u552f\u4e00\u6807\u8bc6\u3002\u9664\u6b64\u4e4b\u5916\u8fd8\u6709\u5176\u4ed6\u5206\u5e03\u5f0f\u573a\u666f\u5bf9\u5206\u5e03\u5f0fID\u7684\u4e00\u4e9b\u8981\u6c42\uff1a<\/p>\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px; visibility: visible;\">\n<li style=\"outline: 0px; visibility: visible;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101; visibility: visible;\"><strong style=\"outline: 0px; color: black; visibility: visible;\">\u8d8b\u52bf\u9012\u589e\uff1a<\/strong>\u00a0\u7531\u4e8e\u591a\u6570RDBMS\u4f7f\u7528B-tree\u7684\u6570\u636e\u7ed3\u6784\u6765\u5b58\u50a8\u7d22\u5f15\u6570\u636e\uff0c\u5728\u4e3b\u952e\u7684\u9009\u62e9\u4e0a\u9762\u6211\u4eec\u5e94\u8be5\u5c3d\u91cf\u4f7f\u7528\u6709\u5e8f\u7684\u4e3b\u952e\u4fdd\u8bc1\u5199\u5165\u6027\u80fd\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px; visibility: visible;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101; visibility: visible;\"><strong style=\"outline: 0px; color: black; visibility: visible;\">\u5355\u8c03\u9012\u589e\uff1a<\/strong>\u00a0\u4fdd\u8bc1\u4e0b\u4e00\u4e2aID\u4e00\u5b9a\u5927\u4e8e\u4e0a\u4e00\u4e2aID\uff0c\u4f8b\u5982\u6392\u5e8f\u9700\u6c42\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px; visibility: visible;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101; visibility: visible;\"><strong style=\"outline: 0px; color: black; visibility: visible;\">\u4fe1\u606f\u5b89\u5168\uff1a<\/strong>\u00a0\u5982\u679cID\u662f\u8fde\u7eed\u7684\uff0c\u6076\u610f\u7528\u6237\u7684\u6252\u53d6\u5de5\u4f5c\u5c31\u975e\u5e38\u5bb9\u6613\u505a\u4e86\uff1b\u5982\u679c\u662f\u8ba2\u5355\u53f7\u5c31\u66f4\u5371\u9669\u4e86\uff0c\u53ef\u4ee5\u76f4\u63a5\u77e5\u9053\u6211\u4eec\u7684\u5355\u91cf\u3002\u6240\u4ee5\u5728\u4e00\u4e9b\u5e94\u7528\u573a\u666f\u4e0b\uff0c\u4f1a\u9700\u8981ID\u65e0\u89c4\u5219\u3001\u4e0d\u89c4\u5219\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; visibility: visible;\">\u5c31\u4e0d\u540c\u7684\u573a\u666f\u53ca\u8981\u6c42\uff0c\u5e02\u9762\u8bde\u751f\u4e86\u5f88\u591a\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\u3002\u672c\u6587\u9488\u5bf9\u591a\u4e2a\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\u8fdb\u884c\u4ecb\u7ecd\uff0c\u5305\u62ec\u5176\u4f18\u7f3a\u70b9\u3001\u4f7f\u7528\u573a\u666f\u53ca\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688; visibility: visible;\">1\u3001UUID<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; visibility: visible;\">UUID(<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688; visibility: visible;\">Universally Unique Identifier<\/code>)\u662f\u57fa\u4e8e\u5f53\u524d\u65f6\u95f4\u3001\u8ba1\u6570\u5668\uff08counter\uff09\u548c\u786c\u4ef6\u6807\u8bc6\uff08\u901a\u5e38\u4e3a\u65e0\u7ebf\u7f51\u5361\u7684MAC\u5730\u5740\uff09\u7b49\u6570\u636e\u8ba1\u7b97\u751f\u6210\u7684\u3002\u5305\u542b32\u4e2a16\u8fdb\u5236\u6570\u5b57\uff0c\u4ee5\u8fde\u5b57\u53f7\u5206\u4e3a\u4e94\u6bb5\uff0c\u5f62\u5f0f\u4e3a8-4-4-4-12\u768436\u4e2a\u5b57\u7b26\uff0c\u53ef\u4ee5\u751f\u6210\u5168\u7403\u552f\u4e00\u7684\u7f16\u7801\u5e76\u4e14\u6027\u80fd\u9ad8\u6548\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; visibility: visible;\">JDK\u63d0\u4f9b\u4e86UUID\u751f\u6210\u5de5\u5177\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px; visibility: visible;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px; visibility: visible;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px; visibility: visible;\">import<\/span>\u00a0java.util.UUID;<br style=\"outline: 0px; visibility: visible;\" \/><br style=\"outline: 0px; visibility: visible;\" \/><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">Test<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(UUID.randomUUID());<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u8f93\u51fa\u5982\u4e0b<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 1em; outline: 0px; border-left-width: 2px; border-left-color: #888888; color: #777777; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; background: rgba(0, 0, 0, 0.05); border-right: 2px solid #888888;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 16px; color: black; line-height: 26px;\">b0378f6a-eeb7-4779-bffe-2a9f3bc76380<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">UUID\u5b8c\u5168\u53ef\u4ee5\u6ee1\u8db3\u5206\u5e03\u5f0f\u552f\u4e00\u6807\u8bc6\uff0c\u4f46\u662f\u5728\u5b9e\u9645\u5e94\u7528\u8fc7\u7a0b\u4e2d\u4e00\u822c\u4e0d\u91c7\u7528\uff0c\u6709\u5982\u4e0b\u51e0\u4e2a\u539f\u56e0\uff1a<\/p>\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u5b58\u50a8\u6210\u672c\u9ad8\uff1a<\/strong>\u00a0UUID\u592a\u957f\uff0c16\u5b57\u8282128\u4f4d\uff0c\u901a\u5e38\u4ee536\u957f\u5ea6\u7684\u5b57\u7b26\u4e32\u8868\u793a\uff0c\u5f88\u591a\u573a\u666f\u4e0d\u9002\u7528\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u4fe1\u606f\u4e0d\u5b89\u5168\uff1a<\/strong>\u00a0\u57fa\u4e8eMAC\u5730\u5740\u751f\u6210\u7684UUID\u7b97\u6cd5\u4f1a\u66b4\u9732MAC\u5730\u5740\uff0c\u66fe\u7ecf\u6885\u4e3d\u838e\u75c5\u6bd2\u7684\u5236\u9020\u8005\u5c31\u662f\u6839\u636eUUID\u5bfb\u627e\u7684\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u4e0d\u7b26\u5408MySQL\u4e3b\u952e\u8981\u6c42\uff1a<\/strong>\u00a0MySQL\u5b98\u65b9\u6709\u660e\u786e\u7684\u5efa\u8bae\u4e3b\u952e\u8981\u5c3d\u91cf\u8d8a\u77ed\u8d8a\u597d\uff0c\u56e0\u4e3a\u592a\u957f\u5bf9MySQL\u7d22\u5f15\u4e0d\u5229\uff1a\u5982\u679c\u4f5c\u4e3a\u6570\u636e\u5e93\u4e3b\u952e\uff0c\u5728InnoDB\u5f15\u64ce\u4e0b\uff0cUUID\u7684\u65e0\u5e8f\u6027\u53ef\u80fd\u4f1a\u5f15\u8d77\u6570\u636e\u4f4d\u7f6e\u9891\u7e41\u53d8\u52a8\uff0c\u4e25\u91cd\u5f71\u54cd\u6027\u80fd\u3002<\/section>\n<\/li>\n<\/ul>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">2\u3001\u6570\u636e\u5e93\u81ea\u589eID<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u5229\u7528Mysql\u7684\u7279\u6027ID\u81ea\u589e\uff0c\u53ef\u4ee5\u8fbe\u5230\u6570\u636e\u552f\u4e00\u6807\u8bc6\uff0c\u4f46\u662f\u5206\u5e93\u5206\u8868\u540e\u53ea\u80fd\u4fdd\u8bc1\u4e00\u4e2a\u8868\u4e2d\u7684ID\u7684\u552f\u4e00\uff0c\u800c\u4e0d\u80fd\u4fdd\u8bc1\u6574\u4f53\u7684ID\u552f\u4e00\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u6709\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u89e3\u51b3\u8be5\u95ee\u9898\u3002<\/p>\n<h3 style=\"margin: 0.6em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 20px; border-left: 2px solid #009688;\">2.1\u3001\u4e3b\u952e\u8868<\/h3>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u901a\u8fc7\u5355\u72ec\u521b\u5efa\u4e3b\u952e\u8868\u7ef4\u62a4\u552f\u4e00\u6807\u8bc6\uff0c\u4f5c\u4e3aID\u7684\u8f93\u51fa\u6e90\u53ef\u4ee5\u4fdd\u8bc1\u6574\u4f53ID\u7684\u552f\u4e00\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u521b\u5efa\u4e00\u4e2a\u4e3b\u952e\u8868<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">CREATE<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">TABLE<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`unique_id`<\/span>\u00a0\u00a0(<br style=\"outline: 0px;\" \/>\u00a0\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`id`<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">bigint<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>\u00a0AUTO_INCREMENT,<br style=\"outline: 0px;\" \/>\u00a0\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`biz`<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">char<\/span>(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1<\/span>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>,<br style=\"outline: 0px;\" \/>\u00a0\u00a0PRIMARY\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">KEY<\/span>\u00a0(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`id`<\/span>),<br style=\"outline: 0px;\" \/>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">UNIQUE<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">KEY<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`biz`<\/span>\u00a0(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`biz`<\/span>)<br style=\"outline: 0px;\" \/>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">ENGINE<\/span>\u00a0=\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">InnoDB<\/span>\u00a0AUTO_INCREMENT=<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">DEFAULT<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">CHARSET<\/span>\u00a0=utf8;<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u4e1a\u52a1\u901a\u8fc7\u66f4\u65b0\u64cd\u4f5c\u6765\u83b7\u53d6ID\u4fe1\u606f\uff0c\u7136\u540e\u6dfb\u52a0\u5230\u67d0\u4e2a\u5206\u8868\u4e2d\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">BEGIN<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">REPLACE<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">INTO<\/span>\u00a0unique_id\u00a0(biz)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">values<\/span>\u00a0(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">'o'<\/span>)\u00a0;<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">SELECT<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">LAST_INSERT_ID<\/span>();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">COMMIT<\/span>;<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<h3 style=\"margin: 0.6em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 20px; border-left: 2px solid #009688;\">2.2\u3001ID\u81ea\u589e\u6b65\u957f\u8bbe\u7f6e<\/h3>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6eMysql\u4e3b\u952e\u81ea\u589e\u6b65\u957f\uff0c\u8ba9\u5206\u5e03\u5728\u4e0d\u540c\u5b9e\u4f8b\u7684\u8868\u6570\u636eID\u505a\u5230\u4e0d\u91cd\u590d\uff0c\u4fdd\u8bc1\u6574\u4f53\u7684\u552f\u4e00\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u5982\u4e0b\uff0c\u53ef\u4ee5\u8bbe\u7f6eMysql\u5b9e\u4f8b1\u6b65\u957f\u4e3a1\uff0c\u5b9e\u4f8b1\u6b65\u957f\u4e3a2\u3002<\/p>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141430313.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141430313.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u67e5\u770b\u4e3b\u952e\u81ea\u589e\u7684\u5c5e\u6027<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">show<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">variables<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">like<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">'%increment%'<\/span><br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141432566.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141432566.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u663e\u7136\uff0c\u8fd9\u79cd\u65b9\u5f0f\u5728\u5e76\u53d1\u91cf\u6bd4\u8f83\u9ad8\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u4f55\u4fdd\u8bc1\u6269\u5c55\u6027\u5176\u5b9e\u4f1a\u662f\u4e00\u4e2a\u95ee\u9898\u3002<\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">3\u3001\u53f7\u6bb5\u6a21\u5f0f<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u53f7\u6bb5\u6a21\u5f0f\u662f\u5f53\u4e0b\u5206\u5e03\u5f0fID\u751f\u6210\u5668\u7684\u4e3b\u6d41\u5b9e\u73b0\u65b9\u5f0f\u4e4b\u4e00\u3002\u5176\u539f\u7406\u5982\u4e0b\uff1a<\/p>\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u53f7\u6bb5\u6a21\u5f0f\u6bcf\u6b21\u4ece\u6570\u636e\u5e93\u53d6\u51fa\u4e00\u4e2a\u53f7\u6bb5\u8303\u56f4\uff0c\u52a0\u8f7d\u5230\u670d\u52a1\u5185\u5b58\u4e2d\u3002\u4e1a\u52a1\u83b7\u53d6\u65f6ID\u76f4\u63a5\u5728\u8fd9\u4e2a\u8303\u56f4\u9012\u589e\u53d6\u503c\u5373\u53ef\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u7b49\u8fd9\u6279\u53f7\u6bb5ID\u7528\u5b8c\uff0c\u518d\u6b21\u5411\u6570\u636e\u5e93\u7533\u8bf7\u65b0\u53f7\u6bb5\uff0c\u5bf9max_id\u5b57\u6bb5\u505a\u4e00\u6b21update\u64cd\u4f5c\uff0c\u65b0\u7684\u53f7\u6bb5\u8303\u56f4\u662f(<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">max_id<\/code>\u00a0,<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">max_id +step<\/code>]\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u7531\u4e8e\u591a\u4e1a\u52a1\u7aef\u53ef\u80fd\u540c\u65f6\u64cd\u4f5c\uff0c\u6240\u4ee5\u91c7\u7528\u7248\u672c\u53f7version\u4e50\u89c2\u9501\u65b9\u5f0f\u66f4\u65b0\u3002<\/section>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141433561.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141433561.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u4f8b\u5982 (1,1000] \u4ee3\u88681000\u4e2aID\uff0c\u5177\u4f53\u7684\u4e1a\u52a1\u670d\u52a1\u5c06\u672c\u53f7\u6bb5\u751f\u62101~1000\u7684\u81ea\u589eID\u3002\u8868\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">CREATE<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">TABLE<\/span>\u00a0id_generator\u00a0(<br style=\"outline: 0px;\" \/>\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">id<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">int<\/span>(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">10<\/span>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>,<br style=\"outline: 0px;\" \/>\u00a0\u00a0max_id\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">bigint<\/span>(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">20<\/span>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">COMMENT<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">'\u5f53\u524d\u6700\u5927id'<\/span>,<br style=\"outline: 0px;\" \/>\u00a0\u00a0step\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">int<\/span>(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">20<\/span>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">COMMENT<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">'\u53f7\u6bb5\u7684\u957f\u5ea6'<\/span>,<br style=\"outline: 0px;\" \/>\u00a0\u00a0biz_type\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">int<\/span>(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">20<\/span>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">COMMENT<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">'\u4e1a\u52a1\u7c7b\u578b'<\/span>,<br style=\"outline: 0px;\" \/>\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">version<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">int<\/span>(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">20<\/span>)\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">NOT<\/span>\u00a0<span style=\"outline: 0px; color: #56b6c2; line-height: 26px;\">NULL<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">COMMENT<\/span>\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">'\u7248\u672c\u53f7,\u662f\u4e00\u4e2a\u4e50\u89c2\u9501\uff0c\u6bcf\u6b21\u90fd\u66f4\u65b0version\uff0c\u4fdd\u8bc1\u5e76\u53d1\u65f6\u6570\u636e\u7684\u6b63\u786e\u6027'<\/span>,<br style=\"outline: 0px;\" \/>\u00a0\u00a0PRIMARY\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">KEY<\/span>\u00a0(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">`id`<\/span>)<br style=\"outline: 0px;\" \/>)\u00a0<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u8fd9\u79cd\u5206\u5e03\u5f0fID\u751f\u6210\u65b9\u5f0f\u4e0d\u5f3a\u4f9d\u8d56\u4e8e\u6570\u636e\u5e93\uff0c\u4e0d\u4f1a\u9891\u7e41\u7684\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u5bf9\u6570\u636e\u5e93\u7684\u538b\u529b\u5c0f\u5f88\u591a\u3002\u4f46\u540c\u6837\u4e5f\u4f1a\u5b58\u5728\u4e00\u4e9b\u7f3a\u70b9\u6bd4\u5982\uff1a\u670d\u52a1\u5668\u91cd\u542f\uff0c\u5355\u70b9\u6545\u969c\u4f1a\u9020\u6210ID\u4e0d\u8fde\u7eed\u3002<\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">4\u3001Redis INCR<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u57fa\u4e8e\u5168\u5c40\u552f\u4e00ID\u7684\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7Redis\u7684INCR\u547d\u4ee4\u6765\u751f\u6210\u5168\u5c40\u552f\u4e00ID\u3002<\/p>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141436502.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141436502.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">Redis\u5206\u5e03\u5f0fID\u7684\u7b80\u5355\u6848\u4f8b<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px;\"><span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0*\u00a0\u00a0Redis\u00a0\u5206\u5e03\u5f0fID\u751f\u6210\u5668<br style=\"outline: 0px;\" \/>\u00a0*\/<\/span><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">@Component<\/span><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">RedisDistributedId<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">@Autowired<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0StringRedisTemplate\u00a0redisTemplate;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0BEGIN_TIMESTAMP\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1659312000l<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u751f\u6210\u5206\u5e03\u5f0fID<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u7b26\u53f7\u4f4d\u00a0\u00a0\u00a0\u00a0\u65f6\u95f4\u6233[31\u4f4d]\u00a0\u00a0\u81ea\u589e\u5e8f\u53f7\u301032\u4f4d\u3011<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@param<\/span>\u00a0item<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@return<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">nextId<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0item)<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a01.\u751f\u6210\u65f6\u95f4\u6233<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LocalDateTime\u00a0now\u00a0=\u00a0LocalDateTime.now();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0\u683c\u6797\u5a01\u6cbb\u65f6\u95f4\u5dee<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0nowSecond\u00a0=\u00a0now.toEpochSecond(ZoneOffset.UTC);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6211\u4eec\u9700\u8981\u83b7\u53d6\u7684\u00a0\u65f6\u95f4\u6233\u00a0\u4fe1\u606f<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0timestamp\u00a0=\u00a0nowSecond\u00a0-\u00a0BEGIN_TIMESTAMP;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a02.\u751f\u6210\u5e8f\u53f7\u00a0--\u300b\u00a0\u4eceRedis\u4e2d\u83b7\u53d6<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5f53\u524d\u5f53\u524d\u7684\u65e5\u671f<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0String\u00a0date\u00a0=\u00a0now.format(DateTimeFormatter.ofPattern(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">\"yyyy:MM:dd\"<\/span>));<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0\u83b7\u53d6\u5bf9\u5e94\u7684\u81ea\u589e\u7684\u5e8f\u53f7<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Long\u00a0increment\u00a0=\u00a0redisTemplate.opsForValue().increment(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">\"id:\"<\/span>\u00a0+\u00a0item\u00a0+\u00a0<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">\":\"<\/span>\u00a0+\u00a0date);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">return<\/span>\u00a0timestamp\u00a0&lt;&lt;\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">32<\/span>\u00a0|\u00a0increment;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u540c\u6837\u4f7f\u7528Redis\u4e5f\u6709\u5bf9\u5e94\u7684\u7f3a\u70b9\uff1aID \u751f\u6210\u7684\u6301\u4e45\u5316\u95ee\u9898\uff0c\u5982\u679cRedis\u5b95\u673a\u4e86\u600e\u4e48\u8fdb\u884c\u6062\u590d?<\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">5\u3001\u96ea\u82b1\u7b97\u6cd5<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">Snowflake\uff0c\u96ea\u82b1\u7b97\u6cd5\u662f\u6709Twitter\u5f00\u6e90\u7684\u5206\u5e03\u5f0fID\u751f\u6210\u7b97\u6cd5\uff0c\u4ee5\u5212\u5206\u547d\u540d\u7a7a\u95f4\u7684\u65b9\u5f0f\u5c0664bit\u4f4d\u5206\u5272\u6210\u4e86\u591a\u4e2a\u90e8\u5206\uff0c\u6bcf\u4e2a\u90e8\u5206\u90fd\u6709\u5177\u4f53\u7684\u4e0d\u540c\u542b\u4e49\uff0c\u5728Java\u4e2d64Bit\u4f4d\u7684\u6574\u6570\u662fLong\u7c7b\u578b\uff0c\u6240\u4ee5\u5728Java\u4e2dSnowflake\u7b97\u6cd5\u751f\u6210\u7684ID\u5c31\u662flong\u6765\u5b58\u50a8\u7684\u3002\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141437129.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141437129.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u7b2c\u4e00\u90e8\u5206\uff1a<\/strong>\u00a0\u5360\u75281bit\uff0c\u7b2c\u4e00\u4f4d\u4e3a\u7b26\u53f7\u4f4d\uff0c\u4e0d\u9002\u7528<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u7b2c\u4e8c\u90e8\u5206\uff1a<\/strong>\u00a041\u4f4d\u7684\u65f6\u95f4\u6233\uff0c41bit\u4f4d\u53ef\u4ee5\u8868\u793a241\u4e2a\u6570\uff0c\u6bcf\u4e2a\u6570\u4ee3\u8868\u7684\u662f\u6beb\u79d2\uff0c\u90a3\u4e48\u96ea\u82b1\u7b97\u6cd5\u7684\u65f6\u95f4\u5e74\u9650\u662f<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">(241)\/(1000\u00d760\u00d760\u00d724\u00d7365)=69<\/code>\u5e74<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u7b2c\u4e09\u90e8\u5206\uff1a<\/strong>\u00a010bit\u8868\u793a\u662f\u673a\u5668\u6570\uff0c\u5373\u00a0<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">2^ 10 = 1024<\/code>\u53f0\u673a\u5668\uff0c\u901a\u5e38\u4e0d\u4f1a\u90e8\u7f72\u8fd9\u4e48\u591a\u673a\u5668<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\"><strong style=\"outline: 0px; color: black;\">\u7b2c\u56db\u90e8\u5206\uff1a<\/strong>\u00a012bit\u4f4d\u662f\u81ea\u589e\u5e8f\u5217\uff0c\u53ef\u4ee5\u8868\u793a<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">2^12=4096<\/code>\u4e2a\u6570\uff0c\u4e00\u79d2\u5185\u53ef\u4ee5\u751f\u62104096\u4e2aID\uff0c\u7406\u8bba\u4e0asnowflake\u65b9\u6848\u7684QPS\u7ea6\u4e3a<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">409.6w\/s<\/code><\/section>\n<\/li>\n<\/ul>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u96ea\u82b1\u7b97\u6cd5\u6848\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #abb2bf; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #282c34; border-radius: 5px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #e6c07b; line-height: 26px;\">SnowflakeIdWorker<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0==============================Fields===========================================<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u5f00\u59cb\u65f6\u95f4\u622a\u00a0(2020-11-03\uff0c\u4e00\u65e6\u786e\u5b9a\u4e0d\u53ef\u66f4\u6539\uff0c\u5426\u5219\u65f6\u95f4\u88ab\u56de\u8c03\uff0c\u6216\u8005\u6539\u53d8\uff0c\u53ef\u80fd\u4f1a\u9020\u6210id\u91cd\u590d\u6216\u51b2\u7a81)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0twepoch\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1604374294980L<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u673a\u5668id\u6240\u5360\u7684\u4f4d\u6570<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0workerIdBits\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">5L<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6570\u636e\u6807\u8bc6id\u6240\u5360\u7684\u4f4d\u6570<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0datacenterIdBits\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">5L<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u652f\u6301\u7684\u6700\u5927\u673a\u5668id\uff0c\u7ed3\u679c\u662f31\u00a0(\u8fd9\u4e2a\u79fb\u4f4d\u7b97\u6cd5\u53ef\u4ee5\u5f88\u5feb\u7684\u8ba1\u7b97\u51fa\u51e0\u4f4d\u4e8c\u8fdb\u5236\u6570\u6240\u80fd\u8868\u793a\u7684\u6700\u5927\u5341\u8fdb\u5236\u6570)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0maxWorkerId\u00a0=\u00a0-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>\u00a0^\u00a0(-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>\u00a0&lt;&lt;\u00a0workerIdBits);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u652f\u6301\u7684\u6700\u5927\u6570\u636e\u6807\u8bc6id\uff0c\u7ed3\u679c\u662f31<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0maxDatacenterId\u00a0=\u00a0-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>\u00a0^\u00a0(-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>\u00a0&lt;&lt;\u00a0datacenterIdBits);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u5e8f\u5217\u5728id\u4e2d\u5360\u7684\u4f4d\u6570<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0sequenceBits\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">12L<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u673a\u5668ID\u5411\u5de6\u79fb12\u4f4d<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0workerIdShift\u00a0=\u00a0sequenceBits;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6570\u636e\u6807\u8bc6id\u5411\u5de6\u79fb17\u4f4d(12+5)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0datacenterIdShift\u00a0=\u00a0sequenceBits\u00a0+\u00a0workerIdBits;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u65f6\u95f4\u622a\u5411\u5de6\u79fb22\u4f4d(5+5+12)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0timestampLeftShift\u00a0=\u00a0sequenceBits\u00a0+\u00a0workerIdBits\u00a0+\u00a0datacenterIdBits;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u751f\u6210\u5e8f\u5217\u7684\u63a9\u7801\uff0c\u8fd9\u91cc\u4e3a4095\u00a0(0b111111111111=0xfff=4095)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">final<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0sequenceMask\u00a0=\u00a0-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>\u00a0^\u00a0(-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>\u00a0&lt;&lt;\u00a0sequenceBits);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u5de5\u4f5c\u673a\u5668ID(0~31)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0workerId;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6570\u636e\u4e2d\u5fc3ID(0~31)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0datacenterId;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6beb\u79d2\u5185\u5e8f\u5217(0~4095)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0sequence\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0L<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u4e0a\u6b21\u751f\u6210ID\u7684\u65f6\u95f4\u622a<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0lastTimestamp\u00a0=\u00a0-<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1L<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/==============================Constructors=====================================<\/span><br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6784\u9020\u51fd\u6570<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">SnowflakeIdWorker<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">this<\/span>.workerId\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0L<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">this<\/span>.datacenterId\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0L<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6784\u9020\u51fd\u6570<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@param<\/span>\u00a0workerId\u00a0\u00a0\u00a0\u00a0\u00a0\u5de5\u4f5cID\u00a0(0~31)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@param<\/span>\u00a0datacenterId\u00a0\u6570\u636e\u4e2d\u5fc3ID\u00a0(0~31)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">SnowflakeIdWorker<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0workerId,\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0datacenterId)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">if<\/span>\u00a0(workerId\u00a0&gt;\u00a0maxWorkerId\u00a0||\u00a0workerId\u00a0&lt;\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">new<\/span>\u00a0IllegalArgumentException(String.format(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">\"worker\u00a0Id\u00a0can't\u00a0be\u00a0greater\u00a0than\u00a0%d\u00a0or\u00a0less\u00a0than\u00a00\"<\/span>,\u00a0maxWorkerId));<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">if<\/span>\u00a0(datacenterId\u00a0&gt;\u00a0maxDatacenterId\u00a0||\u00a0datacenterId\u00a0&lt;\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">new<\/span>\u00a0IllegalArgumentException(String.format(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">\"datacenter\u00a0Id\u00a0can't\u00a0be\u00a0greater\u00a0than\u00a0%d\u00a0or\u00a0less\u00a0than\u00a00\"<\/span>,\u00a0maxDatacenterId));<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">this<\/span>.workerId\u00a0=\u00a0workerId;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">this<\/span>.datacenterId\u00a0=\u00a0datacenterId;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0==============================Methods==========================================<\/span><br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u83b7\u5f97\u4e0b\u4e00\u4e2aID\u00a0(\u8be5\u65b9\u6cd5\u662f\u7ebf\u7a0b\u5b89\u5168\u7684)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@return<\/span>\u00a0SnowflakeId<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">synchronized<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">nextId<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0timestamp\u00a0=\u00a0timeGen();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u5982\u679c\u5f53\u524d\u65f6\u95f4\u5c0f\u4e8e\u4e0a\u4e00\u6b21ID\u751f\u6210\u7684\u65f6\u95f4\u6233\uff0c\u8bf4\u660e\u7cfb\u7edf\u65f6\u949f\u56de\u9000\u8fc7\u8fd9\u4e2a\u65f6\u5019\u5e94\u5f53\u629b\u51fa\u5f02\u5e38<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">if<\/span>\u00a0(timestamp\u00a0&lt;\u00a0lastTimestamp)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">new<\/span>\u00a0RuntimeException(<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0String.format(<span style=\"outline: 0px; color: #98c379; line-height: 26px;\">\"Clock\u00a0moved\u00a0backwards.\u00a0\u00a0Refusing\u00a0to\u00a0generate\u00a0id\u00a0for\u00a0%d\u00a0milliseconds\"<\/span>,\u00a0lastTimestamp\u00a0-\u00a0timestamp));<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u5982\u679c\u662f\u540c\u4e00\u65f6\u95f4\u751f\u6210\u7684\uff0c\u5219\u8fdb\u884c\u6beb\u79d2\u5185\u5e8f\u5217<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">if<\/span>\u00a0(lastTimestamp\u00a0==\u00a0timestamp)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sequence\u00a0=\u00a0(sequence\u00a0+\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1<\/span>)\u00a0&amp;\u00a0sequenceMask;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u6beb\u79d2\u5185\u5e8f\u5217\u6ea2\u51fa<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">if<\/span>\u00a0(sequence\u00a0==\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u963b\u585e\u5230\u4e0b\u4e00\u4e2a\u6beb\u79d2,\u83b7\u5f97\u65b0\u7684\u65f6\u95f4\u6233<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0timestamp\u00a0=\u00a0tilNextMillis(lastTimestamp);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u65f6\u95f4\u6233\u6539\u53d8\uff0c\u6beb\u79d2\u5185\u5e8f\u5217\u91cd\u7f6e<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sequence\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0L<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u4e0a\u6b21\u751f\u6210ID\u7684\u65f6\u95f4\u622a<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0lastTimestamp\u00a0=\u00a0timestamp;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u79fb\u4f4d\u5e76\u901a\u8fc7\u6216\u8fd0\u7b97\u62fc\u5230\u4e00\u8d77\u7ec4\u621064\u4f4d\u7684ID<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">return<\/span>\u00a0((timestamp\u00a0-\u00a0twepoch)\u00a0&lt;&lt;\u00a0timestampLeftShift)\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0|\u00a0(datacenterId\u00a0&lt;&lt;\u00a0datacenterIdShift)\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0|\u00a0(workerId\u00a0&lt;&lt;\u00a0workerIdShift)\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0|\u00a0sequence;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u963b\u585e\u5230\u4e0b\u4e00\u4e2a\u6beb\u79d2\uff0c\u76f4\u5230\u83b7\u5f97\u65b0\u7684\u65f6\u95f4\u6233<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@param<\/span>\u00a0lastTimestamp\u00a0\u4e0a\u6b21\u751f\u6210ID\u7684\u65f6\u95f4\u622a<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@return<\/span>\u00a0\u5f53\u524d\u65f6\u95f4\u6233<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">tilNextMillis<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0lastTimestamp)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0timestamp\u00a0=\u00a0timeGen();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">while<\/span>\u00a0(timestamp\u00a0&lt;=\u00a0lastTimestamp)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0timestamp\u00a0=\u00a0timeGen();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">return<\/span>\u00a0timestamp;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u8fd4\u56de\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u7684\u5f53\u524d\u65f6\u95f4<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@return<\/span>\u00a0\u5f53\u524d\u65f6\u95f4(\u6beb\u79d2)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">timeGen<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">return<\/span>\u00a0System.currentTimeMillis();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u968f\u673aid\u751f\u6210\uff0c\u4f7f\u7528\u96ea\u82b1\u7b97\u6cd5<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">@return<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">static<\/span>\u00a0String\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">getSnowId<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SnowflakeIdWorker\u00a0sf\u00a0=\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">new<\/span>\u00a0SnowflakeIdWorker();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0String\u00a0id\u00a0=\u00a0String.valueOf(sf.nextId());<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">return<\/span>\u00a0id;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/\/=========================================Test=========================================<\/span><br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #5c6370; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0\u6d4b\u8bd5<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; color: #61aeee; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SnowflakeIdWorker\u00a0idWorker\u00a0=\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">new<\/span>\u00a0SnowflakeIdWorker(<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0<\/span>,\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">for<\/span>\u00a0(<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">int<\/span>\u00a0i\u00a0=\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">0<\/span>;\u00a0i\u00a0&lt;\u00a0<span style=\"outline: 0px; color: #d19a66; line-height: 26px;\">1000<\/span>;\u00a0i++)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #c678dd; line-height: 26px;\">long<\/span>\u00a0id\u00a0=\u00a0idWorker.nextId();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(id);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u96ea\u82b1\u7b97\u6cd5\u5f3a\u4f9d\u8d56\u673a\u5668\u65f6\u949f\uff0c\u5982\u679c\u673a\u5668\u4e0a\u65f6\u949f\u56de\u62e8\uff0c\u4f1a\u5bfc\u81f4\u53d1\u53f7\u91cd\u590d\u3002\u901a\u5e38\u901a\u8fc7\u8bb0\u5f55\u6700\u540e\u4f7f\u7528\u65f6\u95f4\u5904\u7406\u8be5\u95ee\u9898\u3002<\/p>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141439784.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141439784.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">6\u3001\u7f8e\u56e2(Leaf)<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u7531\u7f8e\u56e2\u5f00\u53d1\uff0c\u5f00\u6e90\u9879\u76ee\u94fe\u63a5\uff1a<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 1em; outline: 0px; border-left-width: 2px; border-left-color: #888888; color: #777777; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; background: rgba(0, 0, 0, 0.05); border-right: 2px solid #888888;\">\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px; color: black;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">https:\/\/github.com\/Meituan-Dianping\/Leaf<\/section>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">Leaf\u540c\u65f6\u652f\u6301\u53f7\u6bb5\u6a21\u5f0f\u548csnowflake\u7b97\u6cd5\u6a21\u5f0f\uff0c\u53ef\u4ee5\u5207\u6362\u4f7f\u7528\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">snowflake\u6a21\u5f0f\u4f9d\u8d56\u4e8eZooKeeper\uff0c\u4e0d\u540c\u4e8e\u539f\u59cbsnowflake\u7b97\u6cd5\u4e5f\u4e3b\u8981\u662f\u5728workId\u7684\u751f\u6210\u4e0a\uff0cLeaf\u4e2dworkId\u662f\u57fa\u4e8eZooKeeper\u7684\u987a\u5e8fId\u6765\u751f\u6210\u7684\uff0c\u6bcf\u4e2a\u5e94\u7528\u5728\u4f7f\u7528Leaf-snowflake\u65f6\uff0c\u542f\u52a8\u65f6\u90fd\u4f1a\u90fd\u5728Zookeeper\u4e2d\u751f\u6210\u4e00\u4e2a\u987a\u5e8fId\uff0c\u76f8\u5f53\u4e8e\u4e00\u53f0\u673a\u5668\u5bf9\u5e94\u4e00\u4e2a\u987a\u5e8f\u8282\u70b9\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2aworkId\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u53f7\u6bb5\u6a21\u5f0f\u662f\u5bf9\u76f4\u63a5\u7528\u6570\u636e\u5e93\u81ea\u589eID\u5145\u5f53\u5206\u5e03\u5f0fID\u7684\u4e00\u79cd\u4f18\u5316\uff0c\u51cf\u5c11\u5bf9\u6570\u636e\u5e93\u7684\u9891\u7387\u64cd\u4f5c\u3002\u76f8\u5f53\u4e8e\u4ece\u6570\u636e\u5e93\u6279\u91cf\u7684\u83b7\u53d6\u81ea\u589eID\uff0c\u6bcf\u6b21\u4ece\u6570\u636e\u5e93\u53d6\u51fa\u4e00\u4e2a\u53f7\u6bb5\u8303\u56f4\uff0c\u4f8b\u5982 (1,1000] \u4ee3\u88681000\u4e2aID\uff0c\u4e1a\u52a1\u670d\u52a1\u5c06\u53f7\u6bb5\u5728\u672c\u5730\u751f\u62101~1000\u7684\u81ea\u589eID\u5e76\u52a0\u8f7d\u5230\u5185\u5b58\u3002<\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">7\u3001\u767e\u5ea6(Uidgenerator)<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u6e90\u7801\u5730\u5740\uff1a<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 1em; outline: 0px; border-left-width: 2px; border-left-color: #888888; color: #777777; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; background: rgba(0, 0, 0, 0.05); border-right: 2px solid #888888;\">\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px; color: black;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">https:\/\/github.com\/baidu\/uid-generator<\/section>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u4e2d\u6587\u6587\u6863\u5730\u5740\uff1a<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 1em; outline: 0px; border-left-width: 2px; border-left-color: #888888; color: #777777; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; background: rgba(0, 0, 0, 0.05); border-right: 2px solid #888888;\">\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px; color: black;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/README.zh_cn.md<\/section>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">UidGenerator\u662f\u767e\u5ea6\u5f00\u6e90\u7684Java\u8bed\u8a00\u5b9e\u73b0\uff0c\u57fa\u4e8eSnowflake\u7b97\u6cd5\u7684\u552f\u4e00ID\u751f\u6210\u5668\u3002\u5b83\u662f\u5206\u5e03\u5f0f\u7684\uff0c\u5e76\u514b\u670d\u4e86\u96ea\u82b1\u7b97\u6cd5\u7684\u5e76\u53d1\u9650\u5236\u3002\u5355\u4e2a\u5b9e\u4f8b\u7684QPS\u80fd\u8d85\u8fc76000000\u3002\u9700\u8981\u7684\u73af\u5883\uff1aJDK8+\uff0cMySQL\uff08\u7528\u4e8e\u5206\u914dWorkerId\uff09\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u767e\u5ea6\u7684Uidgenerator\u5bf9\u7ed3\u6784\u505a\u4e86\u90e8\u5206\u7684\u8c03\u6574\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141442122.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141442122.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u65f6\u95f4\u90e8\u5206\u53ea\u670928\u4f4d\uff0c\u8fd9\u5c31\u610f\u5473\u7740UidGenerator\u9ed8\u8ba4\u53ea\u80fd\u627f\u53d78.5\u5e74\uff08<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">2^28-1\/86400\/365<\/code>\uff09\uff0c\u4e0d\u8fc7UidGenerator\u53ef\u4ee5\u9002\u5f53\u8c03\u6574delta seconds\u3001worker node id\u548csequence\u5360\u7528\u4f4d\u6570\u3002<\/p>\n<h2 style=\"margin: 1em auto; padding-left: 10px; outline: 0px; font-weight: bold; font-size: 22px; color: #009688; border-left: 3px solid #009688;\">8\u3001\u6ef4\u6ef4(TinyID)<\/h2>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u7531\u6ef4\u6ef4\u5f00\u53d1\uff0c\u5f00\u6e90\u9879\u76ee\u94fe\u63a5\uff1a<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 1em; outline: 0px; border-left-width: 2px; border-left-color: #888888; color: #777777; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; background: rgba(0, 0, 0, 0.05); border-right: 2px solid #888888;\">\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px; color: black;\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">https:\/\/github.com\/didi\/tinyid<\/section>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">Tinyid\u662f\u5728\u7f8e\u56e2\uff08Leaf\uff09\u7684<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">leaf-segment<\/code>\u7b97\u6cd5\u57fa\u7840\u4e0a\u5347\u7ea7\u800c\u6765\uff0c\u4e0d\u4ec5\u652f\u6301\u4e86\u6570\u636e\u5e93\u591a\u4e3b\u8282\u70b9\u6a21\u5f0f\uff0c\u8fd8\u63d0\u4f9b\u4e86<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">tinyid-client<\/code>\u5ba2\u6237\u7aef\u7684\u63a5\u5165\u65b9\u5f0f\uff0c\u4f7f\u7528\u8d77\u6765\u66f4\u52a0\u65b9\u4fbf\u3002\u4f46\u548c\u7f8e\u56e2\uff08Leaf\uff09\u4e0d\u540c\u7684\u662f\uff0cTinyid\u53ea\u652f\u6301\u53f7\u6bb5\u4e00\u79cd\u6a21\u5f0f\u4e0d\u652f\u6301\u96ea\u82b1\u6a21\u5f0f\u3002Tinyid\u63d0\u4f9b\u4e86\u4e24\u79cd\u8c03\u7528\u65b9\u5f0f\uff0c\u4e00\u79cd\u57fa\u4e8e<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">Tinyid-server<\/code>\u63d0\u4f9b\u7684http\u65b9\u5f0f\uff0c\u53e6\u4e00\u79cd<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; font-size: 14px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #009688;\">Tinyid-client<\/code>\u5ba2\u6237\u7aef\u65b9\u5f0f\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\">\u603b\u7ed3\u6bd4\u8f83<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141443246.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" title=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141443246.png\" alt=\"\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01\" \/><\/noscript><\/p>\n<\/section>\n<section class=\"mp_profile_iframe_wrp\"><\/section>\n<p style=\"display: none;\">\n<blockquote class=\"keep-source\"><p>\u539f\u6587\u59cb\u53d1\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7\uff08\u7a0b\u5e8f\u733fDD\uff09\uff1a<a href=\"http:\/\/mp.weixin.qq.com\/s\/ML2V8r1uzH01Vs3U8jJEyA\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\" >\u4e5d\u79cd\u5206\u5e03\u5f0fID\u89e3\u51b3\u65b9\u6848\uff0c\u603b\u6709\u4e00\u6b3e\u9002\u5408\u4f60\uff01<\/a><\/p><\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u5728\u590d\u6742\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u5f80\u5f80\u9700\u8981\u5bf9\u5927\u91cf\u7684\u6570\u636e\u8fdb\u884c\u552f\u4e00\u6807\u8bc6\uff0c\u6bd4\u5982\u5728\u5bf9\u4e00\u4e2a\u8ba2\u5355\u8868\u8fdb\u884c\u4e86\u5206\u5e93\u5206\u8868\u64cd\u4f5c\uff0c\u8fd9\u65f6\u5019\u6570\u636e\u5e93\u7684\u81ea\u589eID\u663e\u7136\u4e0d\u80fd &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-java"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141427456.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141430313.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141430313.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141432566.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141432566.png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141433561.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141433561.png","id":"image7"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141436502.png","id":"image8"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141436502.png","id":"image9"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141437129.png","id":"image10"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141437129.png","id":"image11"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141439784.png","id":"image12"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141439784.png","id":"image13"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141442122.png","id":"image14"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141442122.png","id":"image15"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141443246.png","id":"image16"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230522141443246.png","id":"image17"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Java","post_date":"2023-05-22","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":361,"next_post_id":184,"next_post_title":"\u4f1astream\u6d41\u5c31\u4f1a\u5927\u6570\u636e\uff01","previous_post_id":2036,"previous_post_title":"\u8be6\u89e3\u8bbe\u8ba1\u6a21\u5f0f\uff08\u591a\u56fe + \u4ee3\u7801\uff09","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/171","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=171"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/171\/revisions"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}