{"id":3286,"date":"2018-10-29T10:41:36","date_gmt":"2018-10-29T02:41:36","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3286"},"modified":"2018-10-29T10:41:36","modified_gmt":"2018-10-29T02:41:36","slug":"%e7%99%be%e5%ba%a6%e5%bc%80%e6%ba%90%e7%9a%84-uidgenerator-%e5%94%af%e4%b8%80id-%e7%94%9f%e6%88%90%e5%99%a8%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3286","title":{"rendered":"\u767e\u5ea6\u5f00\u6e90\u7684 UidGenerator (\u552f\u4e00ID) \u751f\u6210\u5668\u4f7f\u7528\u6559\u7a0b"},"content":{"rendered":"<p>\n\tUidGenerator\u662fJava\u5b9e\u73b0\u7684, \u57fa\u4e8e<a href=\"https:\/\/github.com\/twitter\/snowflake\">Snowflake<\/a>\u7b97\u6cd5\u7684\u552f\u4e00ID\u751f\u6210\u5668\u3002UidGenerator\u4ee5\u7ec4\u4ef6\u5f62\u5f0f\u5de5\u4f5c\u5728\u5e94\u7528\u9879\u76ee\u4e2d, \u652f\u6301\u81ea\u5b9a\u4e49workerId\u4f4d\u6570\u548c\u521d\u59cb\u5316\u7b56\u7565, \u4ece\u800c\u9002\u7528\u4e8e<a href=\"https:\/\/www.docker.com\/\" rel=\"nofollow\">docker<\/a>\u7b49\u865a\u62df\u5316\u73af\u5883\u4e0b\u5b9e\u4f8b\u81ea\u52a8\u91cd\u542f\u3001\u6f02\u79fb\u7b49\u573a\u666f\u3002 \u5728\u5b9e\u73b0\u4e0a, UidGenerator\u901a\u8fc7\u501f\u7528\u672a\u6765\u65f6\u95f4\u6765\u89e3\u51b3sequence\u5929\u7136\u5b58\u5728\u7684\u5e76\u53d1\u9650\u5236; \u91c7\u7528RingBuffer\u6765\u7f13\u5b58\u5df2\u751f\u6210\u7684UID, \u5e76\u884c\u5316UID\u7684\u751f\u4ea7\u548c\u6d88\u8d39, \u540c\u65f6\u5bf9CacheLine\u8865\u9f50\uff0c\u907f\u514d\u4e86\u7531RingBuffer\u5e26\u6765\u7684\u786c\u4ef6\u7ea7\u300c\u4f2a\u5171\u4eab\u300d\u95ee\u9898. \u6700\u7ec8\u5355\u673aQPS\u53ef\u8fbe600\u4e07\u3002\n<\/p>\n<p>\n\t\u4f9d\u8d56\u7248\u672c\uff1a<a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html\" rel=\"nofollow\">Java8<\/a>\u53ca\u4ee5\u4e0a\u7248\u672c,&nbsp;<a href=\"https:\/\/dev.mysql.com\/downloads\/mysql\/\" rel=\"nofollow\">MySQL<\/a>(\u5185\u7f6eWorkerID\u5206\u914d\u5668, \u542f\u52a8\u9636\u6bb5\u901a\u8fc7DB\u8fdb\u884c\u5206\u914d; \u5982\u81ea\u5b9a\u4e49\u5b9e\u73b0, \u5219DB\u975e\u5fc5\u9009\u4f9d\u8d56\uff09\n<\/p>\n<h2>\n\tSnowflake\u7b97\u6cd5<br \/>\n<\/h2>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/doc\/snowflake.png\" rel=\"noopener noreferrer\" target=\"_blank\"><img decoding=\"async\" alt=\"Snowflake\" src=\"https:\/\/github.com\/baidu\/uid-generator\/raw\/master\/doc\/snowflake.png\" \/><\/a><br \/>\n\tSnowflake\u7b97\u6cd5\u63cf\u8ff0\uff1a\u6307\u5b9a\u673a\u5668 &amp; \u540c\u4e00\u65f6\u523b &amp; \u67d0\u4e00\u5e76\u53d1\u5e8f\u5217\uff0c\u662f\u552f\u4e00\u7684\u3002\u636e\u6b64\u53ef\u751f\u6210\u4e00\u4e2a64 bits\u7684\u552f\u4e00ID\uff08long\uff09\u3002\u9ed8\u8ba4\u91c7\u7528\u4e0a\u56fe\u5b57\u8282\u5206\u914d\u65b9\u5f0f\uff1a\n<\/p>\n<ul>\n<li>\n<p>\n\t\t\tsign(1bit)<br \/>\n\t\t\t\u56fa\u5b9a1bit\u7b26\u53f7\u6807\u8bc6\uff0c\u5373\u751f\u6210\u7684UID\u4e3a\u6b63\u6570\u3002\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\tdelta seconds (28 bits)<br \/>\n\t\t\t\u5f53\u524d\u65f6\u95f4\uff0c\u76f8\u5bf9\u4e8e\u65f6\u95f4\u57fa\u70b9&quot;2016-05-20&quot;\u7684\u589e\u91cf\u503c\uff0c\u5355\u4f4d\uff1a\u79d2\uff0c\u6700\u591a\u53ef\u652f\u6301\u7ea68.7\u5e74\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\tworker id (22 bits)<br \/>\n\t\t\t\u673a\u5668id\uff0c\u6700\u591a\u53ef\u652f\u6301\u7ea6420w\u6b21\u673a\u5668\u542f\u52a8\u3002\u5185\u7f6e\u5b9e\u73b0\u4e3a\u5728\u542f\u52a8\u65f6\u7531\u6570\u636e\u5e93\u5206\u914d\uff0c\u9ed8\u8ba4\u5206\u914d\u7b56\u7565\u4e3a\u7528\u540e\u5373\u5f03\uff0c\u540e\u7eed\u53ef\u63d0\u4f9b\u590d\u7528\u7b56\u7565\u3002\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\tsequence (13 bits)<br \/>\n\t\t\t\u6bcf\u79d2\u4e0b\u7684\u5e76\u53d1\u5e8f\u5217\uff0c13 bits\u53ef\u652f\u6301\u6bcf\u79d28192\u4e2a\u5e76\u53d1\u3002\n\t\t<\/p>\n<\/li>\n<\/ul>\n<p>\n\t<strong>\u4ee5\u4e0a\u53c2\u6570\u5747\u53ef\u901a\u8fc7Spring\u8fdb\u884c\u81ea\u5b9a\u4e49<\/strong>\n<\/p>\n<h2>\n\tCachedUidGenerator<br \/>\n<\/h2>\n<p>\n\tRingBuffer\u73af\u5f62\u6570\u7ec4\uff0c\u6570\u7ec4\u6bcf\u4e2a\u5143\u7d20\u6210\u4e3a\u4e00\u4e2aslot\u3002RingBuffer\u5bb9\u91cf\uff0c\u9ed8\u8ba4\u4e3aSnowflake\u7b97\u6cd5\u4e2dsequence\u6700\u5927\u503c\uff0c\u4e14\u4e3a2^N\u3002\u53ef\u901a\u8fc7<code>boostPower<\/code>\u914d\u7f6e\u8fdb\u884c\u6269\u5bb9\uff0c\u4ee5\u63d0\u9ad8RingBuffer \u8bfb\u5199\u541e\u5410\u91cf\u3002\n<\/p>\n<p>\n\tTail\u6307\u9488\u3001Cursor\u6307\u9488\u7528\u4e8e\u73af\u5f62\u6570\u7ec4\u4e0a\u8bfb\u5199slot\uff1a\n<\/p>\n<ul>\n<li>\n<p>\n\t\t\tTail\u6307\u9488<br \/>\n\t\t\t\u8868\u793aProducer\u751f\u4ea7\u7684\u6700\u5927\u5e8f\u53f7(\u6b64\u5e8f\u53f7\u4ece0\u5f00\u59cb\uff0c\u6301\u7eed\u9012\u589e)\u3002Tail\u4e0d\u80fd\u8d85\u8fc7Cursor\uff0c\u5373\u751f\u4ea7\u8005\u4e0d\u80fd\u8986\u76d6\u672a\u6d88\u8d39\u7684slot\u3002\u5f53Tail\u5df2\u8d76\u4e0acurosr\uff0c\u6b64\u65f6\u53ef\u901a\u8fc7<code>rejectedPutBufferHandler<\/code>\u6307\u5b9aPutRejectPolicy\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\tCursor\u6307\u9488<br \/>\n\t\t\t\u8868\u793aConsumer\u6d88\u8d39\u5230\u7684\u6700\u5c0f\u5e8f\u53f7(\u5e8f\u53f7\u5e8f\u5217\u4e0eProducer\u5e8f\u5217\u76f8\u540c)\u3002Cursor\u4e0d\u80fd\u8d85\u8fc7Tail\uff0c\u5373\u4e0d\u80fd\u6d88\u8d39\u672a\u751f\u4ea7\u7684slot\u3002\u5f53Cursor\u5df2\u8d76\u4e0atail\uff0c\u6b64\u65f6\u53ef\u901a\u8fc7<code>rejectedTakeBufferHandler<\/code>\u6307\u5b9aTakeRejectPolicy\n\t\t<\/p>\n<\/li>\n<\/ul>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/doc\/ringbuffer.png\" rel=\"noopener noreferrer\" target=\"_blank\"><img decoding=\"async\" alt=\"RingBuffer\" src=\"https:\/\/github.com\/baidu\/uid-generator\/raw\/master\/doc\/ringbuffer.png\" \/><\/a>\n<\/p>\n<p>\n\tCachedUidGenerator\u91c7\u7528\u4e86\u53ccRingBuffer\uff0cUid-RingBuffer\u7528\u4e8e\u5b58\u50a8Uid\u3001Flag-RingBuffer\u7528\u4e8e\u5b58\u50a8Uid\u72b6\u6001(\u662f\u5426\u53ef\u586b\u5145\u3001\u662f\u5426\u53ef\u6d88\u8d39)\n<\/p>\n<p>\n\t\u7531\u4e8e\u6570\u7ec4\u5143\u7d20\u5728\u5185\u5b58\u4e2d\u662f\u8fde\u7eed\u5206\u914d\u7684\uff0c\u53ef\u6700\u5927\u7a0b\u5ea6\u5229\u7528CPU cache\u4ee5\u63d0\u5347\u6027\u80fd\u3002\u4f46\u540c\u65f6\u4f1a\u5e26\u6765\u300c\u4f2a\u5171\u4eab\u300dFalseSharing\u95ee\u9898\uff0c\u4e3a\u6b64\u5728Tail\u3001Cursor\u6307\u9488\u3001Flag-RingBuffer\u4e2d\u91c7\u7528\u4e86CacheLine \u8865\u9f50\u65b9\u5f0f\u3002\n<\/p>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/doc\/cacheline_padding.png\" rel=\"noopener noreferrer\" target=\"_blank\"><img decoding=\"async\" alt=\"FalseSharing\" src=\"https:\/\/github.com\/baidu\/uid-generator\/raw\/master\/doc\/cacheline_padding.png\" \/><\/a>\n<\/p>\n<h4>\n\tRingBuffer\u586b\u5145\u65f6\u673a<br \/>\n<\/h4>\n<ul>\n<li>\n<p>\n\t\t\t\u521d\u59cb\u5316\u9884\u586b\u5145<br \/>\n\t\t\tRingBuffer\u521d\u59cb\u5316\u65f6\uff0c\u9884\u5148\u586b\u5145\u6ee1\u6574\u4e2aRingBuffer.\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\t\u5373\u65f6\u586b\u5145<br \/>\n\t\t\tTake\u6d88\u8d39\u65f6\uff0c\u5373\u65f6\u68c0\u67e5\u5269\u4f59\u53ef\u7528slot\u91cf(<code>tail<\/code>&nbsp;&#8211;&nbsp;<code>cursor<\/code>)\uff0c\u5982\u5c0f\u4e8e\u8bbe\u5b9a\u9608\u503c\uff0c\u5219\u8865\u5168\u7a7a\u95f2slots\u3002\u9608\u503c\u53ef\u901a\u8fc7<code>paddingFactor<\/code>\u6765\u8fdb\u884c\u914d\u7f6e\uff0c\u8bf7\u53c2\u8003Quick Start\u4e2dCachedUidGenerator\u914d\u7f6e\n\t\t<\/p>\n<\/li>\n<li>\n<p>\n\t\t\t\u5468\u671f\u586b\u5145<br \/>\n\t\t\t\u901a\u8fc7Schedule\u7ebf\u7a0b\uff0c\u5b9a\u65f6\u8865\u5168\u7a7a\u95f2slots\u3002\u53ef\u901a\u8fc7<code>scheduleInterval<\/code>\u914d\u7f6e\uff0c\u4ee5\u5e94\u7528\u5b9a\u65f6\u586b\u5145\u529f\u80fd\uff0c\u5e76\u6307\u5b9aSchedule\u65f6\u95f4\u95f4\u9694\n\t\t<\/p>\n<\/li>\n<\/ul>\n<h2>\n\tQuick Start<br \/>\n<\/h2>\n<p>\n\t\u8fd9\u91cc\u4ecb\u7ecd\u5982\u4f55\u5728\u57fa\u4e8eSpring\u7684\u9879\u76ee\u4e2d\u4f7f\u7528UidGenerator, \u5177\u4f53\u6d41\u7a0b\u5982\u4e0b:\n<\/p>\n<h3>\n\t\u6b65\u9aa41: \u5b89\u88c5\u4f9d\u8d56<br \/>\n<\/h3>\n<p>\n\t\u5148\u4e0b\u8f7d<a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html\" rel=\"nofollow\">Java8<\/a>,&nbsp;<a href=\"https:\/\/dev.mysql.com\/downloads\/mysql\/\" rel=\"nofollow\">MySQL<\/a>\u548c<a href=\"https:\/\/maven.apache.org\/download.cgi\" rel=\"nofollow\">Maven<\/a>\n<\/p>\n<h4>\n\t\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<br \/>\n<\/h4>\n<p>\n\tmaven\u65e0\u987b\u5b89\u88c5, \u8bbe\u7f6e\u597dMAVEN_HOME\u5373\u53ef. \u53ef\u50cf\u4e0b\u8ff0\u811a\u672c\u8fd9\u6837\u8bbe\u7f6eJAVA_HOME\u548cMAVEN_HOME, \u5982\u5df2\u8bbe\u7f6e\u8bf7\u5ffd\u7565.\n<\/p>\n<pre class=\"brush:bash;\">\r\nexport MAVEN_HOME=\/xxx\/xxx\/software\/maven\/apache-maven-3.3.9\r\nexport PATH=$MAVEN_HOME\/bin:$PATH\r\nJAVA_HOME=&quot;\/Library\/Java\/JavaVirtualMachines\/jdk1.8.0_91.jdk\/Contents\/Home&quot;;\r\nexport JAVA_HOME;<\/pre>\n<h3>\n\t\u6b65\u9aa42: \u521b\u5efa\u8868WORKER_NODE<br \/>\n<\/h3>\n<p>\n\t\u8fd0\u884csql\u811a\u672c\u4ee5\u5bfc\u5165\u8868WORKER_NODE, \u811a\u672c\u5982\u4e0b:\n<\/p>\n<pre class=\"brush:sql;\">\r\nDROP DATABASE IF EXISTS `xxxx`;\r\nCREATE DATABASE `xxxx` ;\r\nuse `xxxx`;\r\nDROP TABLE IF EXISTS WORKER_NODE;\r\nCREATE TABLE WORKER_NODE\r\n(\r\nID BIGINT NOT NULL AUTO_INCREMENT COMMENT &#039;auto increment id&#039;,\r\nHOST_NAME VARCHAR(64) NOT NULL COMMENT &#039;host name&#039;,\r\nPORT VARCHAR(64) NOT NULL COMMENT &#039;port&#039;,\r\nTYPE INT NOT NULL COMMENT &#039;node type: ACTUAL or CONTAINER&#039;,\r\nLAUNCH_DATE DATE NOT NULL COMMENT &#039;launch date&#039;,\r\nMODIFIED TIMESTAMP NOT NULL COMMENT &#039;modified time&#039;,\r\nCREATED TIMESTAMP NOT NULL COMMENT &#039;created time&#039;,\r\nPRIMARY KEY(ID)\r\n)\r\nCOMMENT=&#039;DB WorkerID Assigner for UID Generator&#039;,ENGINE = INNODB;<\/pre>\n<p>\n\t\u4fee\u6539<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/test\/resources\/uid\/mysql.properties\">mysql.properties<\/a>\u914d\u7f6e\u4e2d, jdbc.url, jdbc.username\u548cjdbc.password, \u786e\u4fdd\u5e93\u5730\u5740, \u540d\u79f0, \u7aef\u53e3\u53f7, \u7528\u6237\u540d\u548c\u5bc6\u7801\u6b63\u786e.\n<\/p>\n<h3>\n\t\u6b65\u9aa43: \u4fee\u6539Spring\u914d\u7f6e<br \/>\n<\/h3>\n<p>\n\t\u63d0\u4f9b\u4e86\u4e24\u79cd\u751f\u6210\u5668:&nbsp;<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/main\/java\/com\/baidu\/fsg\/uid\/impl\/DefaultUidGenerator.java\">DefaultUidGenerator<\/a>\u3001<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/main\/java\/com\/baidu\/fsg\/uid\/impl\/CachedUidGenerator.java\">CachedUidGenerator<\/a>\u3002\u5982\u5bf9UID\u751f\u6210\u6027\u80fd\u6709\u8981\u6c42, \u8bf7\u4f7f\u7528CachedUidGenerator<br \/>\n\t\u5bf9\u5e94Spring\u914d\u7f6e\u5206\u522b\u4e3a:&nbsp;<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/test\/resources\/uid\/default-uid-spring.xml\">default-uid-spring.xml<\/a>\u3001<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/test\/resources\/uid\/cached-uid-spring.xml\">cached-uid-spring.xml<\/a>\n<\/p>\n<h4>\n\tDefaultUidGenerator\u914d\u7f6e<br \/>\n<\/h4>\n<pre class=\"brush:xml;\">\r\n&lt;!-- DefaultUidGenerator --&gt;\r\n&lt;bean id=&quot;defaultUidGenerator&quot; class=&quot;com.baidu.fsg.uid.impl.DefaultUidGenerator&quot; lazy-init=&quot;false&quot;&gt;\r\n    &lt;property name=&quot;workerIdAssigner&quot; ref=&quot;disposableWorkerIdAssigner&quot;\/&gt;\r\n\r\n    &lt;!-- Specified bits &amp; epoch as your demand. No specified the default value will be used --&gt;\r\n    &lt;property name=&quot;timeBits&quot; value=&quot;29&quot;\/&gt;\r\n    &lt;property name=&quot;workerBits&quot; value=&quot;21&quot;\/&gt;\r\n    &lt;property name=&quot;seqBits&quot; value=&quot;13&quot;\/&gt;\r\n    &lt;property name=&quot;epochStr&quot; value=&quot;2016-09-20&quot;\/&gt;\r\n&lt;\/bean&gt;\r\n \r\n&lt;!-- \u7528\u5b8c\u5373\u5f03\u7684WorkerIdAssigner\uff0c\u4f9d\u8d56DB\u64cd\u4f5c --&gt;\r\n&lt;bean id=&quot;disposableWorkerIdAssigner&quot; class=&quot;com.baidu.fsg.uid.worker.DisposableWorkerIdAssigner&quot; \/&gt;<\/pre>\n<h4>\n\tCachedUidGenerator\u914d\u7f6e<br \/>\n<\/h4>\n<pre class=\"brush:xml;\">\r\n&lt;!-- CachedUidGenerator --&gt;\r\n&lt;bean id=&quot;cachedUidGenerator&quot; class=&quot;com.baidu.fsg.uid.impl.CachedUidGenerator&quot;&gt;\r\n    &lt;property name=&quot;workerIdAssigner&quot; ref=&quot;disposableWorkerIdAssigner&quot; \/&gt;\r\n \r\n    &lt;!-- \u4ee5\u4e0b\u4e3a\u53ef\u9009\u914d\u7f6e, \u5982\u672a\u6307\u5b9a\u5c06\u91c7\u7528\u9ed8\u8ba4\u503c --&gt;\r\n    &lt;!-- Specified bits &amp; epoch as your demand. No specified the default value will be used --&gt;\r\n    &lt;property name=&quot;timeBits&quot; value=&quot;29&quot;\/&gt;\r\n    &lt;property name=&quot;workerBits&quot; value=&quot;21&quot;\/&gt;\r\n    &lt;property name=&quot;seqBits&quot; value=&quot;13&quot;\/&gt;\r\n    &lt;property name=&quot;epochStr&quot; value=&quot;2016-09-20&quot;\/&gt;\r\n \r\n    &lt;!-- RingBuffer size\u6269\u5bb9\u53c2\u6570, \u53ef\u63d0\u9ad8UID\u751f\u6210\u7684\u541e\u5410\u91cf. --&gt;\r\n    &lt;!-- \u9ed8\u8ba4:3\uff0c \u539fbufferSize=8192, \u6269\u5bb9\u540ebufferSize= 8192 &lt;&lt; 3 = 65536 --&gt;\r\n    &lt;property name=&quot;boostPower&quot; value=&quot;3&quot;&gt;&lt;\/property&gt;\r\n \r\n    &lt;!-- \u6307\u5b9a\u4f55\u65f6\u5411RingBuffer\u4e2d\u586b\u5145UID, \u53d6\u503c\u4e3a\u767e\u5206\u6bd4(0, 100), \u9ed8\u8ba4\u4e3a50 --&gt;\r\n    &lt;!-- \u4e3e\u4f8b: bufferSize=1024, paddingFactor=50 -&gt; threshold=1024 * 50 \/ 100 = 512. --&gt;\r\n    &lt;!-- \u5f53\u73af\u4e0a\u53ef\u7528UID\u6570\u91cf &lt; 512\u65f6, \u5c06\u81ea\u52a8\u5bf9RingBuffer\u8fdb\u884c\u586b\u5145\u8865\u5168 --&gt;\r\n    &lt;property name=&quot;paddingFactor&quot; value=&quot;50&quot;&gt;&lt;\/property&gt;\r\n \r\n    &lt;!-- \u53e6\u5916\u4e00\u79cdRingBuffer\u586b\u5145\u65f6\u673a, \u5728Schedule\u7ebf\u7a0b\u4e2d, \u5468\u671f\u6027\u68c0\u67e5\u586b\u5145 --&gt;\r\n    &lt;!-- \u9ed8\u8ba4:\u4e0d\u914d\u7f6e\u6b64\u9879, \u5373\u4e0d\u5b9e\u7528Schedule\u7ebf\u7a0b. \u5982\u9700\u4f7f\u7528, \u8bf7\u6307\u5b9aSchedule\u7ebf\u7a0b\u65f6\u95f4\u95f4\u9694, \u5355\u4f4d:\u79d2 --&gt;\r\n    &lt;property name=&quot;scheduleInterval&quot; value=&quot;60&quot;&gt;&lt;\/property&gt;\r\n \r\n    &lt;!-- \u62d2\u7edd\u7b56\u7565: \u5f53\u73af\u5df2\u6ee1, \u65e0\u6cd5\u7ee7\u7eed\u586b\u5145\u65f6 --&gt;\r\n    &lt;!-- \u9ed8\u8ba4\u65e0\u9700\u6307\u5b9a, \u5c06\u4e22\u5f03Put\u64cd\u4f5c, \u4ec5\u65e5\u5fd7\u8bb0\u5f55. \u5982\u6709\u7279\u6b8a\u9700\u6c42, \u8bf7\u5b9e\u73b0RejectedPutBufferHandler\u63a5\u53e3(\u652f\u6301Lambda\u8868\u8fbe\u5f0f) --&gt;\r\n    &lt;property name=&quot;rejectedPutBufferHandler&quot; ref=&quot;XxxxYourPutRejectPolicy&quot;&gt;&lt;\/property&gt;\r\n \r\n    &lt;!-- \u62d2\u7edd\u7b56\u7565: \u5f53\u73af\u5df2\u7a7a, \u65e0\u6cd5\u7ee7\u7eed\u83b7\u53d6\u65f6 --&gt;\r\n    &lt;!-- \u9ed8\u8ba4\u65e0\u9700\u6307\u5b9a, \u5c06\u8bb0\u5f55\u65e5\u5fd7, \u5e76\u629b\u51faUidGenerateException\u5f02\u5e38. \u5982\u6709\u7279\u6b8a\u9700\u6c42, \u8bf7\u5b9e\u73b0RejectedTakeBufferHandler\u63a5\u53e3(\u652f\u6301Lambda\u8868\u8fbe\u5f0f) --&gt;\r\n    &lt;property name=&quot;rejectedTakeBufferHandler&quot; ref=&quot;XxxxYourTakeRejectPolicy&quot;&gt;&lt;\/property&gt;\r\n \r\n&lt;\/bean&gt;\r\n \r\n&lt;!-- \u7528\u5b8c\u5373\u5f03\u7684WorkerIdAssigner, \u4f9d\u8d56DB\u64cd\u4f5c --&gt;\r\n&lt;bean id=&quot;disposableWorkerIdAssigner&quot; class=&quot;com.baidu.fsg.uid.worker.DisposableWorkerIdAssigner&quot; \/&gt;<\/pre>\n<h4>\n\tMybatis\u914d\u7f6e<br \/>\n<\/h4>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/test\/resources\/uid\/mybatis-spring.xml\">mybatis-spring.xml<\/a>\u914d\u7f6e\u8bf4\u660e\u5982\u4e0b:\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;!-- Spring annotation\u626b\u63cf --&gt;\r\n&lt;context:component-scan base-package=&quot;com.baidu.fsg.uid&quot; \/&gt;\r\n\r\n&lt;bean id=&quot;sqlSessionFactory&quot; class=&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;&gt;\r\n    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; \/&gt;\r\n    &lt;property name=&quot;mapperLocations&quot; value=&quot;classpath:\/META-INF\/mybatis\/mapper\/M_WORKER*.xml&quot; \/&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;!-- \u4e8b\u52a1\u76f8\u5173\u914d\u7f6e --&gt;\r\n&lt;tx:annotation-driven transaction-manager=&quot;transactionManager&quot; order=&quot;1&quot; \/&gt;\r\n\r\n&lt;bean id=&quot;transactionManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;\r\n\t&lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; \/&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;!-- Mybatis Mapper\u626b\u63cf --&gt;\r\n&lt;bean class=&quot;org.mybatis.spring.mapper.MapperScannerConfigurer&quot;&gt;\r\n\t&lt;property name=&quot;annotationClass&quot; value=&quot;org.springframework.stereotype.Repository&quot; \/&gt;\r\n\t&lt;property name=&quot;basePackage&quot; value=&quot;com.baidu.fsg.uid.worker.dao&quot; \/&gt;\r\n\t&lt;property name=&quot;sqlSessionFactoryBeanName&quot; value=&quot;sqlSessionFactory&quot; \/&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;!-- \u6570\u636e\u6e90\u914d\u7f6e --&gt;\r\n&lt;bean id=&quot;dataSource&quot; parent=&quot;abstractDataSource&quot;&gt;\r\n\t&lt;property name=&quot;driverClassName&quot; value=&quot;${mysql.driver}&quot; \/&gt;\r\n\t&lt;property name=&quot;maxActive&quot; value=&quot;${jdbc.maxActive}&quot; \/&gt;\r\n\t&lt;property name=&quot;url&quot; value=&quot;${jdbc.url}&quot; \/&gt;\r\n\t&lt;property name=&quot;username&quot; value=&quot;${jdbc.username}&quot; \/&gt;\r\n\t&lt;property name=&quot;password&quot; value=&quot;${jdbc.password}&quot; \/&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;bean id=&quot;abstractDataSource&quot; class=&quot;com.alibaba.druid.pool.DruidDataSource&quot; destroy-method=&quot;close&quot;&gt;\r\n\t&lt;property name=&quot;filters&quot; value=&quot;${datasource.filters}&quot; \/&gt;\r\n\t&lt;property name=&quot;defaultAutoCommit&quot; value=&quot;${datasource.defaultAutoCommit}&quot; \/&gt;\r\n\t&lt;property name=&quot;initialSize&quot; value=&quot;${datasource.initialSize}&quot; \/&gt;\r\n\t&lt;property name=&quot;minIdle&quot; value=&quot;${datasource.minIdle}&quot; \/&gt;\r\n\t&lt;property name=&quot;maxWait&quot; value=&quot;${datasource.maxWait}&quot; \/&gt;\r\n\t&lt;property name=&quot;testWhileIdle&quot; value=&quot;${datasource.testWhileIdle}&quot; \/&gt;\r\n\t&lt;property name=&quot;testOnBorrow&quot; value=&quot;${datasource.testOnBorrow}&quot; \/&gt;\r\n\t&lt;property name=&quot;testOnReturn&quot; value=&quot;${datasource.testOnReturn}&quot; \/&gt;\r\n\t&lt;property name=&quot;validationQuery&quot; value=&quot;${datasource.validationQuery}&quot; \/&gt;\r\n\t&lt;property name=&quot;timeBetweenEvictionRunsMillis&quot; value=&quot;${datasource.timeBetweenEvictionRunsMillis}&quot; \/&gt;\r\n\t&lt;property name=&quot;minEvictableIdleTimeMillis&quot; value=&quot;${datasource.minEvictableIdleTimeMillis}&quot; \/&gt;\r\n\t&lt;property name=&quot;logAbandoned&quot; value=&quot;${datasource.logAbandoned}&quot; \/&gt;\r\n\t&lt;property name=&quot;removeAbandoned&quot; value=&quot;${datasource.removeAbandoned}&quot; \/&gt;\r\n\t&lt;property name=&quot;removeAbandonedTimeout&quot; value=&quot;${datasource.removeAbandonedTimeout}&quot; \/&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;bean id=&quot;batchSqlSession&quot; class=&quot;org.mybatis.spring.SqlSessionTemplate&quot;&gt;\r\n\t&lt;constructor-arg index=&quot;0&quot; ref=&quot;sqlSessionFactory&quot; \/&gt;\r\n\t&lt;constructor-arg index=&quot;1&quot; value=&quot;BATCH&quot; \/&gt;\r\n&lt;\/bean&gt;<\/pre>\n<h3>\n\t\u6b65\u9aa44: \u8fd0\u884c\u793a\u4f8b\u5355\u6d4b<br \/>\n<\/h3>\n<p>\n\t\u8fd0\u884c\u5355\u6d4b<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/src\/test\/java\/com\/baidu\/fsg\/uid\/CachedUidGeneratorTest.java\">CachedUidGeneratorTest<\/a>, \u5c55\u793aUID\u751f\u6210\u3001\u89e3\u6790\u7b49\u529f\u80fd\n<\/p>\n<pre class=\"brush:java;\">\r\n@Resource\r\nprivate UidGenerator uidGenerator;\r\n\r\n@Test\r\npublic void testSerialGenerate() {\r\n    \/\/ Generate UID\r\n    long uid = uidGenerator.getUID();\r\n\r\n    \/\/ Parse UID into [Timestamp, WorkerId, Sequence]\r\n    \/\/ {&quot;UID&quot;:&quot;180363646902239241&quot;,&quot;parsed&quot;:{    &quot;timestamp&quot;:&quot;2017-01-19 12:15:46&quot;,    &quot;workerId&quot;:&quot;4&quot;,    &quot;sequence&quot;:&quot;9&quot;        }}\r\n    System.out.println(uidGenerator.parseUID(uid));\r\n\r\n}<\/pre>\n<h3>\n\t\u5173\u4e8eUID\u6bd4\u7279\u5206\u914d\u7684\u5efa\u8bae<br \/>\n<\/h3>\n<p>\n\t\u5bf9\u4e8e\u5e76\u53d1\u6570\u8981\u6c42\u4e0d\u9ad8\u3001\u671f\u671b\u957f\u671f\u4f7f\u7528\u7684\u5e94\u7528, \u53ef\u589e\u52a0<code>timeBits<\/code>\u4f4d\u6570, \u51cf\u5c11<code>seqBits<\/code>\u4f4d\u6570. \u4f8b\u5982\u8282\u70b9\u91c7\u53d6\u7528\u5b8c\u5373\u5f03\u7684WorkerIdAssigner\u7b56\u7565, \u91cd\u542f\u9891\u7387\u4e3a12\u6b21\/\u5929, \u90a3\u4e48\u914d\u7f6e\u6210<code>{&quot;workerBits&quot;:23,&quot;timeBits&quot;:31,&quot;seqBits&quot;:9}<\/code>\u65f6, \u53ef\u652f\u630128\u4e2a\u8282\u70b9\u4ee5\u6574\u4f53\u5e76\u53d1\u91cf14400 UID\/s\u7684\u901f\u5ea6\u6301\u7eed\u8fd0\u884c68\u5e74.\n<\/p>\n<p>\n\t\u5bf9\u4e8e\u8282\u70b9\u91cd\u542f\u9891\u7387\u9891\u7e41\u3001\u671f\u671b\u957f\u671f\u4f7f\u7528\u7684\u5e94\u7528, \u53ef\u589e\u52a0<code>workerBits<\/code>\u548c<code>timeBits<\/code>\u4f4d\u6570, \u51cf\u5c11<code>seqBits<\/code>\u4f4d\u6570. \u4f8b\u5982\u8282\u70b9\u91c7\u53d6\u7528\u5b8c\u5373\u5f03\u7684WorkerIdAssigner\u7b56\u7565, \u91cd\u542f\u9891\u7387\u4e3a24*12\u6b21\/\u5929, \u90a3\u4e48\u914d\u7f6e\u6210<code>{&quot;workerBits&quot;:27,&quot;timeBits&quot;:30,&quot;seqBits&quot;:6}<\/code>\u65f6, \u53ef\u652f\u630137\u4e2a\u8282\u70b9\u4ee5\u6574\u4f53\u5e76\u53d1\u91cf2400 UID\/s\u7684\u901f\u5ea6\u6301\u7eed\u8fd0\u884c34\u5e74.\n<\/p>\n<h4>\n\t\u541e\u5410\u91cf\u6d4b\u8bd5<br \/>\n<\/h4>\n<p>\n\t\u5728MacBook Pro\uff082.7GHz Intel Core i5, 8G DDR3\uff09\u4e0a\u8fdb\u884c\u4e86CachedUidGenerator\uff08\u5355\u5b9e\u4f8b\uff09\u7684UID\u541e\u5410\u91cf\u6d4b\u8bd5.&nbsp;<br \/>\n\t\u9996\u5148\u56fa\u5b9a\u4f4fworkerBits\u4e3a\u4efb\u9009\u4e00\u4e2a\u503c(\u598220), \u5206\u522b\u7edf\u8ba1timeBits\u53d8\u5316\u65f6(\u5982\u4ece25\u81f332, \u603b\u65f6\u957f\u5206\u522b\u5bf9\u5e941\u5e74\u548c136\u5e74)\u7684\u541e\u5410\u91cf, \u5982\u4e0b\u8868\u6240\u793a:\n<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\n\t\t\t\ttimeBits\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t25\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t26\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t27\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t28\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t29\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t30\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t31\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t32\n\t\t\t<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\n\t\t\t\tthroughput\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,831,465\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t7,007,279\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,679,625\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,499,205\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,534,971\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t7,617,440\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,186,930\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,364,997\n\t\t\t<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/doc\/throughput1.png\" rel=\"noopener noreferrer\" target=\"_blank\"><img decoding=\"async\" alt=\"throughput1\" src=\"https:\/\/github.com\/baidu\/uid-generator\/raw\/master\/doc\/throughput1.png\" \/><\/a>\n<\/p>\n<p>\n\t\u518d\u56fa\u5b9a\u4f4ftimeBits\u4e3a\u4efb\u9009\u4e00\u4e2a\u503c(\u598231), \u5206\u522b\u7edf\u8ba1workerBits\u53d8\u5316\u65f6(\u5982\u4ece20\u81f329, \u603b\u91cd\u542f\u6b21\u6570\u5206\u522b\u5bf9\u5e941\u767e\u4e07\u548c500\u767e\u4e07)\u7684\u541e\u5410\u91cf, \u5982\u4e0b\u8868\u6240\u793a:\n<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\n\t\t\t\tworkerBits\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t20\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t21\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t22\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t23\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t24\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t25\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t26\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t27\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t28\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t29\n\t\t\t<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\n\t\t\t\tthroughput\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,186,930\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,642,727\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,581,661\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,462,726\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,774,609\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,414,906\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,806,266\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,223,617\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,438,055\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,435,549\n\t\t\t<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/doc\/throughput2.png\" rel=\"noopener noreferrer\" target=\"_blank\"><img decoding=\"async\" alt=\"throughput1\" src=\"https:\/\/github.com\/baidu\/uid-generator\/raw\/master\/doc\/throughput2.png\" \/><\/a>\n<\/p>\n<p>\n\t\u7531\u6b64\u53ef\u89c1, \u4e0d\u7ba1\u5982\u4f55\u914d\u7f6e, CachedUidGenerator\u603b\u80fd\u63d0\u4f9b<strong>600\u4e07\/s<\/strong>\u7684\u7a33\u5b9a\u541e\u5410\u91cf, \u53ea\u662f\u4f7f\u7528\u5e74\u9650\u4f1a\u6709\u6240\u51cf\u5c11. \u8fd9\u771f\u7684\u662f\u592a\u68d2\u4e86.\n<\/p>\n<p>\n\t\u6700\u540e, \u56fa\u5b9a\u4f4fworkerBits\u548ctimeBits\u4f4d\u6570(\u598223\u548c31), \u5206\u522b\u7edf\u8ba1\u4e0d\u540c\u6570\u76ee(\u59821\u81f38,\u672c\u673aCPU\u6838\u6570\u4e3a4)\u7684UID\u4f7f\u7528\u8005\u60c5\u51b5\u4e0b\u7684\u541e\u5410\u91cf,\n<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">\n\t\t\t\tworkerBits\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t1\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t2\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t3\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t4\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t5\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t6\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t7\n\t\t\t<\/th>\n<th align=\"center\">\n\t\t\t\t8\n\t\t\t<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">\n\t\t\t\tthroughput\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,462,726\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,542,259\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,077,717\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,377,958\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t7,002,410\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,599,113\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t7,360,934\n\t\t\t<\/td>\n<td align=\"center\">\n\t\t\t\t6,490,969\n\t\t\t<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t<a href=\"https:\/\/github.com\/baidu\/uid-generator\/blob\/master\/doc\/throughput3.png\" rel=\"noopener noreferrer\" target=\"_blank\"><img decoding=\"async\" alt=\"throughput1\" src=\"https:\/\/github.com\/baidu\/uid-generator\/raw\/master\/doc\/throughput3.png\" \/><\/a><\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3286\">\u767e\u5ea6\u5f00\u6e90\u7684 UidGenerator (\u552f\u4e00ID) \u751f\u6210\u5668\u4f7f\u7528\u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>UidGenerator\u662fJava\u5b9e\u73b0\u7684, \u57fa\u4e8eSnowflake\u7b97\u6cd5\u7684\u552f\u4e00ID\u751f\u6210\u5668\u3002UidGenerato [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[512,1727,1570,1726,1410],"class_list":["post-3286","post","type-post","status-publish","format-standard","hentry","category-java","category-yyzt","tag-docker","tag-java8","tag-snowflake","tag-uidgenerator","tag-uuid"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3286"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3286\/revisions"}],"predecessor-version":[{"id":3287,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3286\/revisions\/3287"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}