{"id":61808,"date":"2026-01-18T16:25:47","date_gmt":"2026-01-18T08:25:47","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/61808.html"},"modified":"2026-01-18T16:25:47","modified_gmt":"2026-01-18T08:25:47","slug":"%e4%b8%80%e7%ab%99%e5%bc%8f%e4%ba%86%e8%a7%a3%e5%85%a8%e5%b1%80%e5%88%86%e5%b8%83%e5%bc%8f%e7%94%9f%e6%88%90id%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/61808.html","title":{"rendered":"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848"},"content":{"rendered":"<hr \/>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u5f15\u8a00<\/li>\n<li>\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528\u81ea\u589e\u4e3b\u952e&#xff1f;<\/li>\n<li>\n<ul>\n<li>\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u56f0\u96be<\/li>\n<li>\u5b89\u5168\u4e0e\u4e1a\u52a1\u98ce\u9669<\/li>\n<li>\n<ul>\n<li>**\u66b4\u9732\u4e1a\u52a1\u89c4\u6a21**<\/li>\n<li>**\u5b89\u5168\u9690\u60a3&#xff1a;ID \u904d\u5386\u653b\u51fb&#xff08;IDOR&#xff09;**<\/li>\n<li>**\u5f71\u54cd A\/B \u6d4b\u8bd5\u6216\u7070\u5ea6\u53d1\u5e03**<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u5206\u5e03\u5f0f\u4e3b\u952e\u7684\u6838\u5fc3\u8981\u6c42<\/li>\n<li>\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848: \u5185\u5916\u5206\u79bb<\/li>\n<li>\n<ul>\n<li>\u5185\u90e8\u4e3b\u952eID<\/li>\n<li>\n<ul>\n<li>\u6570\u636e\u5e93 Seq \u8868\u65b9\u6848 (\u4f20\u7edf\u6a21\u5f0f)<\/li>\n<li>UUID(Universally Unique Identifier)<\/li>\n<li>Redis &#096;INCR&#096;<\/li>\n<li>Snowflake &#8211; \u96ea\u82b1\u7b97\u6cd5&#xff08;\u91cd\u70b9&#xff09;<\/li>\n<li>\n<ul>\n<li>\u7ed3\u6784\u62c6\u89e3<\/li>\n<li>\u4f18\u7f3a\u70b9\u5206\u6790<\/li>\n<li>\u4ec0\u4e48\u662f\u65f6\u949f\u56de\u62e8&#xff1f;<\/li>\n<li>\u4e3a\u4ec0\u4e48\u96ea\u82b1\u7b97\u6cd5\u6015\u56de\u62e8&#xff1f;<\/li>\n<li>\u65f6\u949f\u56de\u62e8\u5e38\u89c1\u5e94\u5bf9\u7b56\u7565&#xff1f;<\/li>\n<\/ul>\n<\/li>\n<li>\u7f8e\u56e2 Leaf\u7b97\u6cd5<\/li>\n<li>\n<ul>\n<li>Leaf-Segment (\u53f7\u6bb5\u6a21\u5f0f)<\/li>\n<li>Leaf-Snowflake (\u81ea\u6108\u96ea\u82b1)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u5916\u90e8ID<\/li>\n<li>\n<ul>\n<li>**\u5916\u90e8 ID \u662f\u5185\u90e8 ID \u7684\u300c\u53ef\u9006\u7f16\u7801\u300d**<\/li>\n<li>**\u5916\u90e8 ID \u662f\u968f\u673a\u751f\u6210 or \u52a0\u5bc6\u6d3e\u751f**<\/li>\n<li>\n<ul>\n<li>\u65b9\u6848 A&#xff1a;**\u5b8c\u5168\u968f\u673a\u751f\u6210**<\/li>\n<li>\u65b9\u6848 B&#xff1a;**HMAC &#043; \u622a\u65ad&#xff08;\u4f2a\u968f\u673a\u4f46\u786e\u5b9a\u6027&#xff09;**<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<li>\n<ul>\n<li>\u7ecf\u9a8c\u4e4b\u8c08<\/li>\n<li>\u6742\u8c08<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u5f15\u8a00<\/h2>\n<p>\u4f5c\u4e3a\u4e00\u540d\u540e\u7aef\u5f00\u53d1\u4eba\u5458&#xff0c;\u7406\u89e3\u5206\u5e03\u5f0f ID \u7684\u6f14\u8fdb\u8fc7\u7a0b&#xff0c;\u672c\u8d28\u4e0a\u662f\u5728\u7406\u89e3\u5982\u4f55\u5728\u5206\u5e03\u5f0f CAP \u7406\u8bba&#xff08;\u4e00\u81f4\u6027\u3001\u53ef\u7528\u6027\u3001\u5206\u533a\u5bb9\u9519\u6027&#xff09;\u4e2d\u5bfb\u627e\u6027\u80fd\u4e0e\u53ef\u9760\u6027\u7684\u5e73\u8861\u70b9\u3002\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d&#xff0c;ID \u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a\u6570\u5b57\u3002\u5b83\u662f\u6570\u636e\u7684\u552f\u4e00\u6807\u8bc6&#xff0c;\u662f\u5206\u5e93\u5206\u8868\u7684\u8def\u7531\u4f9d\u636e&#xff0c;\u66f4\u662f\u7cfb\u7edf\u9ad8\u6027\u80fd\u8fd0\u8f6c\u7684\u57fa\u77f3\u3002\u6240\u4ee5&#xff0c;\u6df1\u5ea6\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u7684\u65b9\u6848\u662f\u975e\u5e38\u6709\u5fc5\u8981\u7684&#xff0c;\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u4e00\u8d77\u63a2\u8ba8\u4e00\u4e0b\u5427&#xff01;<\/p>\n<h2>\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528\u81ea\u589e\u4e3b\u952e&#xff1f;<\/h2>\n<p>\u6709\u540c\u5b66\u8bf4\u4e86&#xff0c;\u6211\u4eec\u4e3a\u5565\u4e0d\u7528\u6570\u636e\u5e93\u53ef\u4ee5\u81ea\u589e\u751f\u6210\u7684\u4e3b\u952e\u5462&#xff1f;\u8fd9\u6837\u540c\u65f6\u8fd8\u80fd\u63d0\u9ad8SQL\u7684\u67e5\u8be2\u901f\u5ea6(B&#043;\u6811)\u3002\u4f60\u5148\u4e0d\u6025&#xff0c;\u4e0d\u4f7f\u7528\u80af\u5b9a\u662f\u56e0\u4e3a\u4f18\u5148\u7ea7\u9ad8\u4e8e\u8fd9\u70b9\u4f18\u5316\u7684\u3002<\/p>\n<h3>\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u56f0\u96be<\/h3>\n<p>\u5728\u5355\u673a\u6570\u636e\u5e93\u4e2d&#xff0c;\u81ea\u589e\u4e3b\u952e&#xff08;\u5982 MySQL \u7684 AUTO_INCREMENT&#xff09;\u7b80\u5355\u9ad8\u6548\u3002\u4f46\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u5b58\u5728\u4ee5\u4e0b\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u65e0\u6cd5\u4fdd\u8bc1\u5168\u5c40\u552f\u4e00&#xff1a;\u591a\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u5404\u81ea\u7ef4\u62a4\u81ea\u5df1\u7684\u81ea\u589e\u503c&#xff0c;\u5bb9\u6613\u51b2\u7a81\u3002<\/li>\n<li>\u4e0d\u5229\u4e8e\u5206\u5e93\u5206\u8868&#xff1a;\u63d2\u5165\u524d\u4e0d\u77e5\u9053\u4e3b\u952e\u503c&#xff0c;\u96be\u4ee5\u786e\u5b9a\u6570\u636e\u5e94\u8def\u7531\u5230\u54ea\u4e2a\u5206\u7247\u3002<\/li>\n<li>\u6027\u80fd\u74f6\u9888&#xff1a;\u96c6\u4e2d\u5f0f\u751f\u6210\u5668\u4f1a\u6210\u4e3a\u5355\u70b9\u74f6\u9888&#xff0c;\u9ad8\u5e76\u53d1\u4e0b\u627f\u538b\u592a\u9ad8\u3002<\/li>\n<\/ul>\n<h3>\u5b89\u5168\u4e0e\u4e1a\u52a1\u98ce\u9669<\/h3>\n<p>\u9664\u4e86\u63d0\u5230\u7684\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u6280\u672f\u9650\u5236&#xff08;\u5982\u5168\u5c40\u552f\u4e00\u6027\u3001\u5206\u7247\u8def\u7531\u3001\u6027\u80fd\u74f6\u9888&#xff09;\u4e4b\u5916&#xff0c;\u81ea\u589e\u4e3b\u952e\u8fd8\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u5b89\u5168\u548c\u4e1a\u52a1\u98ce\u9669&#xff1a;\u5bb9\u6613\u88ab\u5916\u90e8\u731c\u6d4b\u51fa\u6570\u636e\u89c4\u5f8b\u3002\u8fd9\u5728\u5f88\u591a\u5b9e\u9645\u4e1a\u52a1\u573a\u666f\u4e2d\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\u3002<\/p>\n<p>\u636e\u8bf4,\u65e9\u671f Instagram \u7684\u7167\u7247 ID \u662f\u81ea\u589e\u7684&#xff0c;\u7814\u7a76\u4eba\u5458\u901a\u8fc7 ID \u63a8\u7b97\u51fa\u5176\u6bcf\u65e5\u65b0\u589e\u7167\u7247\u91cf&#xff0c;\u5f15\u53d1\u9690\u79c1\u4e89\u8bae\u3002<\/p>\n<h4>\u66b4\u9732\u4e1a\u52a1\u89c4\u6a21<\/h4>\n<ul>\n<li>\n<p>\u6bd4\u5982\u4e00\u4e2a\u7535\u5546\u7f51\u7ad9\u7684\u8ba2\u5355 ID \u662f 10001\u300110002\u2026\u2026<\/p>\n<\/li>\n<li>\n<p>\u7ade\u4e89\u5bf9\u624b\u6216\u7528\u6237\u901a\u8fc7\u89c2\u5bdf ID \u589e\u957f\u901f\u5ea6&#xff0c;\u53ef\u4ee5\u4f30\u7b97&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u5929\/\u6bcf\u5c0f\u65f6\u7684\u8ba2\u5355\u91cf<\/li>\n<li>\u7528\u6237\u6ce8\u518c\u6570\u91cf<\/li>\n<li>\u5185\u5bb9\u53d1\u5e03\u9891\u7387&#xff08;\u5982\u5e16\u5b50\u3001\u8bc4\u8bba\u6570&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8fd9\u76f8\u5f53\u4e8e\u514d\u8d39\u6cc4\u9732\u4e86\u6838\u5fc3\u8fd0\u8425\u6570\u636e<\/p>\n<\/li>\n<\/ul>\n<h4>\u5b89\u5168\u9690\u60a3&#xff1a;ID \u904d\u5386\u653b\u51fb&#xff08;IDOR&#xff09;<\/h4>\n<ul>\n<li>\u5982\u679c URL \u662f https:\/\/example.com\/order\/12345&#xff0c;\u653b\u51fb\u8005\u53ea\u9700\u5c1d\u8bd5 12346\u300112347\u2026\u2026<\/li>\n<li>\u5982\u679c\u6743\u9650\u6821\u9a8c\u4e0d\u4e25&#xff0c;\u5c31\u53ef\u80fd\u8d8a\u6743\u8bbf\u95ee\u4ed6\u4eba\u6570\u636e\u3002<\/li>\n<li>\u5373\u4f7f\u6709\u6743\u9650\u63a7\u5236&#xff0c;\u5927\u91cf\u65e0\u6548\u8bf7\u6c42\u4e5f\u4f1a\u589e\u52a0\u670d\u52a1\u5668\u8d1f\u62c5\u3002<\/li>\n<\/ul>\n<p>\u5b89\u5168\u6700\u4f73\u5b9e\u8df5&#xff1a;\u4e0d\u8981\u4f9d\u8d56\u201c\u9690\u85cf ID\u201d\u6765\u4fdd\u62a4\u6570\u636e&#xff0c;\u4f46\u4f7f\u7528\u4e0d\u53ef\u9884\u6d4b\u7684 ID \u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u653b\u51fb\u6210\u672c<\/p>\n<h4>\u5f71\u54cd A\/B \u6d4b\u8bd5\u6216\u7070\u5ea6\u53d1\u5e03<\/h4>\n<p>\u5982\u679c\u65b0\u529f\u80fd\u53ea\u5bf9\u90e8\u5206\u7528\u6237\u5f00\u653e&#xff0c;\u800c\u7528\u6237 ID \u662f\u8fde\u7eed\u7684&#xff08;\u5982 1&#xff5e;10000 \u662f\u8001\u7528\u6237&#xff0c;10001&#043; \u662f\u65b0\u7528\u6237&#xff09;&#xff0c;\u5bb9\u6613\u88ab\u8bc6\u522b\u51fa\u6d4b\u8bd5\u5206\u7ec4&#xff0c;\u7834\u574f\u5b9e\u9a8c\u6709\u6548\u6027<\/p>\n<h2>\u5206\u5e03\u5f0f\u4e3b\u952e\u7684\u6838\u5fc3\u8981\u6c42<\/h2>\n<p>ok,\u4e0a\u9762\u8bf4\u4e86\u8fd9\u4e48\u591a\u81ea\u589e\u4e3b\u952e\u7684\u574f\u5904&#xff0c;\u6211\u4eec\u6765\u8c08\u8c08\u5206\u5e03\u5f0f\u4e3b\u952e\u7684\u6838\u5fc3\u8981\u6c42<\/p>\n<li>\u5168\u5c40\u552f\u4e00&#xff08;\u5fc5\u987b&#xff09;<\/li>\n<li>\u8d8b\u52bf\u9012\u589e&#xff08;\u6709\u5229\u4e8e\u7d22\u5f15\u6027\u80fd&#xff0c;\u907f\u514d\u968f\u673a\u5199&#xff09;<\/li>\n<li>\u9ad8\u53ef\u7528 &amp; \u9ad8\u6027\u80fd&#xff08;\u4f4e\u5ef6\u8fdf\u3001\u65e0\u5355\u70b9\u6545\u969c&#xff09;<\/li>\n<li>\u53ef\u6269\u5c55&#xff08;\u652f\u6301\u6c34\u5e73\u6269\u5c55&#xff09;<\/li>\n<li>\u5c3d\u91cf\u77ed&#xff08;\u8282\u7701\u5b58\u50a8\u548c\u7d22\u5f15\u7a7a\u95f4&#xff09;<\/li>\n<h2>\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848: \u5185\u5916\u5206\u79bb<\/h2>\n<p>\u5f88\u591a\u5927\u5382\u91c7\u7528\u201c\u5185\u90e8\u4e3b\u952e &#043; \u5916\u90e8\u516c\u5f00 ID\u201d\u7684\u53cc ID \u4f53\u7cfb&#xff0c;\u63a5\u4e0b\u6765\u6211\u4eec\u5206\u5f00\u8c08\u8c08\u5404\u81ea\u53ef\u4ee5\u600e\u4e48\u505a\u3002\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u9700\u8981\u4f7f\u7528&#xff0c;\u4e0d\u4e00\u5b9a\u9700\u8981\u53ccID\u4f53\u7cfb\u3002<\/p>\n<p>\u5982\u4e0b\u56fe\u5c31\u662f\u4e00\u4e2a\u8ba2\u5355\u7f16\u53f7&#xff0c;\u4e5f\u5c31\u662f\u8ba2\u5355\u8868\u7684\u4e3b\u952e\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260118082546-696c990aa49b5.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u5185\u90e8\u4e3b\u952eID<\/h3>\n<p>\u6211\u4eec\u5728\u7a0b\u5e8f\u5185\u7684&#xff0c;\u7ed9\u6570\u636e\u5e93\u5bf9\u5e94\u8868\u7684\u4e3b\u952e\u53ef\u4ee5\u600e\u4e48\u6837\u8bbe\u8ba1\u5462&#xff1f;\u6765\u770b\u770b\u4e0b\u9762\u7684\u65b9\u6848\u5427&#xff0c;\u6709\u4e9b\u65b9\u6848\u5e76\u4e0d\u662f\u5b8c\u5168\u9002\u5408\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u7684\u8981\u6c42&#xff0c;\u6211\u4e4b\u6240\u4ee5\u5217\u51fa\u6765&#xff0c;\u662f\u56e0\u4e3a\u6709\u8fd9\u6837\u7684\u65b9\u6848&#xff0c;\u5927\u5bb6\u53ef\u4ee5\u6309\u9700\u7406\u89e3\u548c\u4f7f\u7528\u3002<\/p>\n<h4>\u6570\u636e\u5e93 Seq \u8868\u65b9\u6848 (\u4f20\u7edf\u6a21\u5f0f)<\/h4>\n<p>\u8fd9\u662f\u6700\u539f\u59cb\u7684\u5206\u5e03\u5f0f ID \u505a\u6cd5&#xff1a;\u5728\u6570\u636e\u5e93\u4e2d\u5efa\u7acb\u4e00\u5f20\u8868&#xff0c;\u8fd9\u4e2a\u8868\u53ea\u6709\u6709\u4e00\u5217&#xff0c;\u4e13\u95e8\u7528\u6765\u8bb0\u5f55 ID\u3002\u4e0d\u540c\u7684\u4e1a\u52a1\u8868\u90fd\u5bf9\u5e94\u6709\u8fd9\u5f20\u8868<\/p>\n<ul>\n<li>\n<p>\u5b9e\u73b0&#xff1a; \u6bcf\u6b21\u9700\u8981 ID \u65f6&#xff0c;\u6267\u884c\u7c7b\u4f3c REPLACE INTO \u6216 UPDATE \u7684\u64cd\u4f5c&#xff0c;\u5229\u7528\u6570\u636e\u5e93\u7684\u81ea\u589e\u5c5e\u6027\u83b7\u53d6\u65b0\u503c\u3002<\/p>\n<\/li>\n<li>\n<p>\u75db\u70b9&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<p>\u6027\u80fd\u74f6\u9888&#xff1a; \u6bcf\u6b21\u751f\u6210 ID \u90fd\u5f97\u8bfb\u5199\u6570\u636e\u5e93&#xff0c;\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b&#xff0c;\u6570\u636e\u5e93\u4f1a\u6210\u4e3a\u4e25\u91cd\u7684\u5355\u70b9\u74f6\u9888\u3002<\/p>\n<p>\u9ad8\u53ef\u7528\u98ce\u9669&#xff1a; \u5982\u679c\u8fd9\u53f0 DB \u5b95\u673a&#xff0c;\u6574\u4e2a\u7cfb\u7edf\u7684\u53d1\u53f7\u529f\u80fd\u5c31\u762b\u75ea\u4e86<\/p>\n<p>\u8868\u975e\u5e38\u591a&#xff1a; \u6bcf\u4e00\u79cd\u8868\u90fd\u9700\u8981\u5bf9\u5e94\u4e00\u5f20\u8fd9\u6837\u7684\u8868&#xff0c;\u90a3\u8fd9\u79cdseq\u8868\u5c31\u4f1a\u975e\u5e38\u591a<\/p>\n<p>\u672c\u8d28&#xff1a; \u8fd9\u79cd\u65b9\u6848\u672c\u8d28\u4e0a\u8fd8\u662f\u81ea\u589e\u7684<\/p>\n<h4>UUID(Universally Unique Identifier)<\/h4>\n<p>\u8fd9\u662f\u6700\u7b80\u5355\u3001\u6700\u4e0d\u4f9d\u8d56\u5916\u90e8\u7cfb\u7edf\u7684\u65b9\u6848\u3002<\/p>\n<ul>\n<li>\n<p>\u5b9e\u73b0&#xff1a; Java \u7684 UUID.randomUUID() \u6216 Go \u7684 google\/uuid \u5e93\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f18\u70b9&#xff1a; \u672c\u5730\u751f\u6210&#xff0c;\u6027\u80fd\u6781\u9ad8&#xff0c;\u65e0\u7f51\u7edc\u5f00\u9500\u3002<\/p>\n<\/li>\n<li>\n<p>\u7f3a\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u65e0\u5e8f&#xff1a; \u4f5c\u4e3a B&#043; \u6811\u4e3b\u952e\u4f1a\u5bfc\u81f4\u9875\u5206\u88c2&#xff0c;\u4e25\u91cd\u5f71\u54cd\u6570\u636e\u5e93\u5199\u5165\u6027\u80fd\u3002<\/li>\n<li>\u4e0d\u53ef\u8bfb&#xff1a; \u6ca1\u6709\u4efb\u4f55\u4e1a\u52a1\u542b\u4e49\u3002<\/li>\n<li>\u592a\u957f&#xff1a; 36 \u4f4d\u5b57\u7b26&#xff0c;\u5360\u7528\u7a7a\u95f4\u5927\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>Redis INCR<\/h4>\n<p>\u5229\u7528 Redis \u7684\u539f\u5b50\u64cd\u4f5c\u751f\u6210 ID\u3002<\/p>\n<ul>\n<li>\u5b9e\u73b0&#xff1a; \u901a\u8fc7 INCR \u547d\u4ee4\u5b9e\u73b0\u81ea\u589e\u3002\u4e3a\u4e86\u63d0\u9ad8\u53ef\u7528\u6027&#xff0c;\u53ef\u4ee5\u91c7\u7528\u591a\u4e2a Redis \u8282\u70b9&#xff0c;\u8bbe\u7f6e\u4e0d\u540c\u7684\u521d\u59cb\u503c\u548c\u76f8\u540c\u7684\u6b65\u957f\u3002<\/li>\n<li>\u4f18\u70b9&#xff1a; \u6027\u80fd\u9ad8\u4e8e\u6570\u636e\u5e93&#xff0c;\u81ea\u589e\u6709\u5e8f\u3002<\/li>\n<li>\u7f3a\u70b9&#xff1a; \u589e\u52a0\u4e86 Redis \u7ef4\u62a4\u6210\u672c&#xff0c;\u4e14\u6570\u636e\u6301\u4e45\u5316&#xff08;RDB\/AOF&#xff09;\u5982\u679c\u914d\u7f6e\u4e0d\u5f53&#xff0c;\u91cd\u542f\u540e\u53ef\u80fd\u5bfc\u81f4 ID \u91cd\u590d\u3002\u672c\u8d28\u4e0a\u8fd8\u662f\u6570\u636e\u5e93\u7684\u65b9\u6848\u53d8\u79cd&#xff0c;\u53ea\u4e0d\u8fc7\u6027\u80fd\u63d0\u9ad8\u4e86\u4e0d\u5c11\u3002<\/li>\n<\/ul>\n<h4>Snowflake &#8211; \u96ea\u82b1\u7b97\u6cd5&#xff08;\u91cd\u70b9&#xff09;<\/h4>\n<p>\u8fd9\u662f\u76ee\u524d\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u6700\u4e3b\u6d41\u7684\u65b9\u6848&#xff0c;Twitter \u5f00\u6e90&#xff0c;\u975e\u5e38\u9002\u5408\u5fae\u670d\u52a1\u73af\u5883\u3002<\/p>\n<h5>\u7ed3\u6784\u62c6\u89e3<\/h5>\n<p>\u96ea\u82b1\u7b97\u6cd5\u751f\u6210\u7684 ID \u662f\u4e00\u4e2a 64 \u4f4d\u7684 long \u578b\u6574\u6570&#xff1a;<\/p>\n<li>1 bit&#xff1a; \u56fa\u5b9a\u4e3a 0&#xff0c;\u8868\u793a\u6b63\u6570\u3002<\/li>\n<li>41 bit&#xff1a; \u65f6\u95f4\u6233&#xff08;\u6beb\u79d2\u7ea7&#xff09;\u3002\u53ef\u4ee5\u4f7f\u7528\u7ea6 69 \u5e74\u3002<\/li>\n<li>10 bit&#xff1a; \u5de5\u4f5c\u673a\u5668 ID\u3002\u53ef\u4ee5\u90e8\u7f72 1024 \u4e2a\u8282\u70b9\u3002<\/li>\n<li>12 bit&#xff1a; \u5e8f\u5217\u53f7\u3002\u540c\u4e00\u6beb\u79d2\u5185\u53ef\u4ea7\u751f 4096 \u4e2a ID\u3002<\/li>\n<h5>\u4f18\u7f3a\u70b9\u5206\u6790<\/h5>\n<ul>\n<li>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u8d8b\u52bf\u9012\u589e&#xff1a; \u6574\u4f53\u6309\u65f6\u95f4\u6392\u5e8f\u3002<\/li>\n<li>\u4e0d\u4f9d\u8d56\u5916\u90e8&#xff1a; \u7eaf\u672c\u5730\u7b97\u6cd5&#xff0c;\u65e0\u7f51\u7edc I\/O\u3002<\/li>\n<li>\u9ad8\u6027\u80fd&#xff1a; \u6bcf\u79d2\u53ef\u4ea7\u751f\u6570\u767e\u4e07\u4e2a ID\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u7f3a\u70b9&#xff1a; \u65f6\u949f\u56de\u62e8&#xff0c; \u8fd9\u662f\u96ea\u82b1\u7b97\u6cd5\u6700\u5927\u7684\u75db\u70b9\u3002\u5982\u679c\u670d\u52a1\u5668\u65f6\u95f4\u88ab\u56de\u62e8&#xff0c;\u53ef\u80fd\u4f1a\u4ea7\u751f\u91cd\u590d ID\u3002<\/p>\n<\/li>\n<\/ul>\n<h5>\u4ec0\u4e48\u662f\u65f6\u949f\u56de\u62e8&#xff1f;<\/h5>\n<p>\u65f6\u949f\u56de\u62e8\u662f\u6307\u7cfb\u7edf\u65f6\u949f\u5728\u8fd0\u884c\u8fc7\u7a0b\u4e2d&#xff0c;\u7531\u4e8e\u67d0\u4e9b\u539f\u56e0\u5bfc\u81f4\u83b7\u53d6\u5230\u7684\u5f53\u524d\u65f6\u95f4\u6233\u6bd4\u4e0a\u4e00\u6b21\u83b7\u53d6\u7684\u65f6\u95f4\u6233\u8fd8\u8981\u5c0f\u7684\u73b0\u8c61\u3002<\/p>\n<p>\u6838\u5fc3\u6210\u56e0<\/p>\n<ul>\n<li>NTP \u5f3a\u884c\u540c\u6b65&#xff1a;\u670d\u52a1\u5668\u901a\u5e38\u4f1a\u901a\u8fc7 NTP (Network Time Protocol) \u534f\u8bae\u4e0e\u65f6\u95f4\u670d\u52a1\u5668\u540c\u6b65\u3002\u5982\u679c\u672c\u5730\u65f6\u949f\u6bd4 NTP \u670d\u52a1\u5668\u5feb&#xff0c;\u540c\u6b65\u65f6\u53ef\u80fd\u4f1a\u5bfc\u81f4\u672c\u5730\u65f6\u95f4\u8df3\u56de\u3002<\/li>\n<li>\u7ba1\u7406\u5458\u624b\u52a8\u4fee\u6539&#xff1a;\u8fd0\u7ef4\u4eba\u5458\u624b\u52a8\u8c03\u6574\u4e86\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u95f4\u3002<\/li>\n<li>\u95f0\u79d2\u8c03\u6574&#xff1a;\u867d\u7136\u7f55\u89c1&#xff0c;\u4f46\u5730\u7403\u81ea\u8f6c\u53d8\u5316\u5bfc\u81f4\u7684\u95f0\u79d2\u8865\u507f\u4e5f\u53ef\u80fd\u5f15\u8d77\u5fae\u5999\u7684\u65f6\u95f4\u8df3\u53d8<\/li>\n<\/ul>\n<h5>\u4e3a\u4ec0\u4e48\u96ea\u82b1\u7b97\u6cd5\u6015\u56de\u62e8&#xff1f;<\/h5>\n<p>\u96ea\u82b1\u7b97\u6cd5\u7684\u6838\u5fc3\u903b\u8f91\u662f&#xff1a;ID &#061; [1\u4f4d\u7b26\u53f7] &#043; [41\u4f4d\u65f6\u95f4\u6233] &#043; [10\u4f4d\u673a\u5668ID] &#043; [12\u4f4d\u5e8f\u5217\u53f7]\u3002<\/p>\n<p>\u5982\u679c\u65f6\u95f4\u53d1\u751f\u4e86\u56de\u62e8&#xff1a;<\/p>\n<li>\u7b97\u6cd5\u5728\u65b0\u7684&#xff08;\u4f46\u8f83\u65e7\u7684&#xff09;\u6beb\u79d2\u5185\u91cd\u65b0\u4ece 0 \u5f00\u59cb\u8ba1\u6570\u3002<\/li>\n<li>\u800c\u8fd9\u4e2a\u65e7\u7684\u6beb\u79d2\u5728\u771f\u5b9e\u65f6\u95f4\u7684\u201c\u8fc7\u53bb\u201d\u5df2\u7ecf\u751f\u6210\u8fc7 ID \u4e86\u3002<\/li>\n<li>\u7ed3\u679c&#xff1a;\u6781\u5927\u6982\u7387\u4ea7\u751f\u4e0e\u8fc7\u53bb\u5b8c\u5168\u76f8\u540c\u7684 ID&#xff0c;\u5bfc\u81f4\u6570\u636e\u5e93\u4e3b\u952e\u51b2\u7a81<\/li>\n<h5>\u65f6\u949f\u56de\u62e8\u5e38\u89c1\u5e94\u5bf9\u7b56\u7565&#xff1f;<\/h5>\n<p>\u65b9\u6848 A&#xff1a;\u629b\u51fa\u5f02\u5e38&#xff08;\u6700\u7b80\u5355&#xff09;<\/p>\n<p>\u5982\u679c\u68c0\u6d4b\u5230\u5f53\u524d\u65f6\u95f4 &lt; \u4e0a\u6b21\u751f\u6210\u65f6\u95f4&#xff0c;\u76f4\u63a5\u62d2\u7edd\u670d\u52a1&#xff0c;\u629b\u51fa\u5f02\u5e38\u544a\u77e5\u4e0a\u5c42\u903b\u8f91\u3002<\/p>\n<p>\u65b9\u6848 B&#xff1a;\u5bb9\u95f4\u7b49\u5f85&#xff08;\u6700\u901a\u7528&#xff09;<\/p>\n<p>\u5982\u679c\u56de\u62e8\u65f6\u95f4\u5f88\u77ed&#xff08;\u4f8b\u5982\u5728 5ms \u4ee5\u5185&#xff09;&#xff0c;\u5219\u8ba9\u7a0b\u5e8f\u7ebf\u7a0b\u963b\u585e&#xff08;Sleep&#xff09;\u7b49\u5f85\u65f6\u95f4\u8ffd\u8d76\u56de\u6765\u3002<\/p>\n<p>\u65b9\u6848 C&#xff1a;\u5907\u7528\u673a\u4f4d&#xff08;\u9ad8\u9636\u65b9\u6848&#xff09;<\/p>\n<p>\u4e3a\u6bcf\u53f0\u673a\u5668\u5206\u914d\u4e24\u4e2a WorkerID\u3002\u5e73\u65f6\u7528 A&#xff0c;\u53d1\u751f\u56de\u62e8\u65f6\u7acb\u5373\u5207\u6362\u5230 B&#xff0c;\u7531\u4e8e\u673a\u5668 ID \u4e0d\u540c&#xff0c;\u5373\u4f7f\u65f6\u95f4\u91cd\u53e0\u4e5f\u4e0d\u4f1a\u4ea7\u751f\u91cd\u590d ID\u3002<\/p>\n<p>\u65b9\u6848 D&#xff1a;\u65f6\u95f4\u8ffd\u8d76&#xff08;\u767e\u5ea6 UidGenerator \u7b56\u7565&#xff09;<\/p>\n<p>\u4e0d\u518d\u83b7\u53d6\u7cfb\u7edf\u65f6\u95f4&#xff0c;\u800c\u662f\u57fa\u4e8e\u4e0a\u4e00\u6b21\u751f\u6210\u7684 ID \u65f6\u95f4\u6233\u5e73\u6ed1\u81ea\u589e\u3002\u5982\u679c\u7cfb\u7edf\u65f6\u95f4\u56de\u62e8&#xff0c;\u903b\u8f91\u65f6\u949f\u4f9d\u7136\u5411\u540e\u8d70<\/p>\n<h4>\u7f8e\u56e2 Leaf\u7b97\u6cd5<\/h4>\n<p>\u7f8e\u56e2\u7684 Leaf \u65b9\u6848\u96c6\u5404\u5bb6\u4e4b\u957f&#xff0c;\u63d0\u4f9b\u4e86\u4e24\u79cd\u6a21\u5f0f&#xff0c;\u89e3\u51b3\u4e86\u4e0a\u8ff0\u65b9\u6848\u7684\u6838\u5fc3\u75db\u70b9\u3002<\/p>\n<h5>Leaf-Segment (\u53f7\u6bb5\u6a21\u5f0f)<\/h5>\n<p>\u8fd9\u662f\u5bf9\u201c\u6570\u636e\u5e93\u81ea\u589e\u201d\u7684\u6df1\u5ea6\u4f18\u5316\u3002<\/p>\n<ul>\n<li>\u539f\u7406&#xff1a;\u4e0d\u518d\u662f\u6bcf\u6b21\u8981 1 \u4e2a ID&#xff0c;\u800c\u662f\u6bcf\u6b21\u4ece\u6570\u636e\u5e93\u6279\u6b21\u83b7\u53d6\u4e00\u4e2a\u53f7\u6bb5&#xff08;\u5982 1000 \u4e2a&#xff09;\u3002<\/li>\n<li>\u6838\u5fc3\u4f18\u5316&#xff1a;\u53cc\u7f13\u5b58 (Double Buffer) \u5f53\u5185\u5b58\u4e2d\u7b2c\u4e00\u4e2a\u53f7\u6bb5\u7528\u6389 10% \u65f6&#xff0c;Leaf \u4f1a\u5f02\u6b65\u542f\u52a8\u4e00\u4e2a\u7ebf\u7a0b\u53bb\u9884\u53d6\u4e0b\u4e00\u4e2a\u53f7\u6bb5\u3002<\/li>\n<li>\u6548\u679c&#xff1a;\u5373\u4f7f\u6570\u636e\u5e93\u77ed\u65f6\u95f4\u5b95\u673a&#xff0c;\u7531\u4e8e\u5185\u5b58\u6709\u7f13\u5b58&#xff0c;\u670d\u52a1\u4f9d\u7136\u53ef\u7528\u3002\u540c\u65f6\u89e3\u51b3\u4e86\u76f4\u63a5\u8bbf\u95ee\u6570\u636e\u5e93\u7684\u6027\u80fd\u6296\u52a8<\/li>\n<\/ul>\n<h5>Leaf-Snowflake (\u81ea\u6108\u96ea\u82b1)<\/h5>\n<p>\u9488\u5bf9\u96ea\u82b1\u7b97\u6cd5\u7684\u4f18\u5316&#xff1a;<\/p>\n<ul>\n<li>\u81ea\u52a8\u5206\u914d WorkerID&#xff1a;\u5229\u7528 ZooKeeper \u7684\u987a\u5e8f\u8282\u70b9\u81ea\u52a8\u6ce8\u518c\u673a\u5668 ID&#xff0c;\u65e0\u9700\u624b\u52a8\u914d\u7f6e\u3002<\/li>\n<li>\u65f6\u949f\u56de\u62e8\u6821\u9a8c&#xff1a;\u542f\u52a8\u65f6\u6821\u9a8c\u65f6\u95f4&#xff0c;\u8fd0\u884c\u4e2d\u5982\u679c\u53d1\u73b0\u56de\u62e8&#xff0c;\u4f1a\u62a5\u9519\u6216\u81ea\u52a8\u7b49\u5f85\u65f6\u95f4\u8ffd\u8d76\u3002<\/li>\n<\/ul>\n<h3>\u5916\u90e8ID<\/h3>\n<p>\u90a3\u4e48\u663e\u793a\u5728\u6d4f\u89c8\u5668\u94fe\u63a5\u7684ID\u6211\u4eec\u53c8\u6709\u4ec0\u4e48\u65b9\u6848\u5462&#xff1f;\u6765\u770b\u770b\u5427<\/p>\n<h4>\u5916\u90e8 ID \u662f\u5185\u90e8 ID \u7684\u300c\u53ef\u9006\u7f16\u7801\u300d<\/h4>\n<p>\u5916\u90e8\u663e\u793aid\u5c31\u52a0\u5bc6\u4e00\u6b21&#xff08;\u5982\u7eaf Base62&#xff09;\u3002<\/p>\n<p>internal_id <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1284756392012345678<\/span><br \/>\npublic_id <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;ord_&#034;<\/span> <span class=\"token operator\">&#043;<\/span> <span class=\"token function\">base62_encode<\/span><span class=\"token punctuation\">(<\/span>internal_id<span class=\"token punctuation\">)<\/span> # \u2192 <span class=\"token string\">&#034;ord_k7mPq9sR&#034;<\/span><\/p>\n<ul>\n<li>Base62 \u7f16\u7801&#xff1a;\u53ea\u662f\u5c06\u5341\u8fdb\u5236\u6570\u5b57\u8f6c\u4e3a 0-9a-zA-Z \u7684\u5b57\u7b26\u4e32\u8868\u793a&#xff08;\u7c7b\u4f3c hex&#xff0c;\u4f46\u66f4\u7d27\u51d1&#xff09;<\/li>\n<li>\u65e0\u54c8\u5e0c\u3001\u65e0\u76d0\u503c&#xff0c;\u662f\u5b8c\u5168\u53ef\u9006\u7684<\/li>\n<li>\u6570\u636e\u5e93\u4ecd\u7528 BIGINT \u5b58 internal_id&#xff0c;\u5bf9\u5916\u5c55\u793a public_id<\/li>\n<li>\u67e5\u8be2\u65f6&#xff1a;\u6536\u5230 ord_k7mPq9sR \u2192 \u53bb\u6389\u524d\u7f00 \u2192 Base62 \u89e3\u7801 \u2192 \u5f97\u5230 1284756392012&#8230; \u2192 \u76f4\u63a5\u67e5\u4e3b\u952e<\/li>\n<\/ul>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u65e0\u989d\u5916\u5b58\u50a8&#xff08;\u4e0d\u9700\u8981\u5b58 public_id \u5b57\u6bb5&#xff09;<\/li>\n<li>\u67e5\u8be2\u9ad8\u6548&#xff08;\u76f4\u63a5\u547d\u4e2d\u4e3b\u952e\u7d22\u5f15&#xff09;<\/li>\n<li>\u4fdd\u8bc1\u552f\u4e00\u6027&#xff08;\u56e0\u4e3a\u5185\u90e8 ID \u552f\u4e00&#xff09;<\/li>\n<\/ul>\n<p>\u7f3a\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u4ecd\u7136\u53ef\u9884\u6d4b&#xff01; \u867d\u7136\u770b\u8d77\u6765\u50cf\u4e71\u7801&#xff0c;\u4f46\u653b\u51fb\u8005\u77e5\u9053\u662f Base62 \u540e&#xff0c;\u53ef\u4ee5\u53cd\u63a8\u5185\u90e8 ID&#xff0c;\u8fdb\u800c\u63a8\u6d4b\u4e1a\u52a1\u91cf\u3002<\/li>\n<li>\u4e0d\u5177\u5907\u201c\u4e0d\u53ef\u731c\u6d4b\u6027\u201d&#xff08;security through obscurity \u2260 security&#xff09;<\/li>\n<\/ul>\n<p>\u7ed3\u8bba&#xff1a;\u8fd9\u79cd\u65b9\u6848\u4e0d\u662f\u771f\u6b63\u7684\u5b89\u5168\u65b9\u6848&#xff0c;\u53ea\u662f\u201c\u7f8e\u5316 ID\u201d\u6216\u201c\u7f29\u77ed URL\u201d&#xff0c;\u4e0d\u80fd\u9632 IDOR \u6216\u9632\u6570\u636e\u63a8\u65ad<\/p>\n<h4>\u5916\u90e8 ID \u662f\u968f\u673a\u751f\u6210 or \u52a0\u5bc6\u6d3e\u751f<\/h4>\n<p>\u8fd9\u79cd\u65b9\u6848\u65e0\u76f4\u63a5\u6570\u5b66\u5bf9\u5e94&#xff0c;\u9700\u989d\u5916\u5b58\u50a8\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n<h5>\u65b9\u6848 A&#xff1a;\u5b8c\u5168\u968f\u673a\u751f\u6210<\/h5>\n<p>public_id &#061; &#034;ord_&#034; &#043; secrets.token_urlsafe(8) # \u2192 &#034;ord_k7mPq9sR&#034;<\/p>\n<ul>\n<li>\u6bcf\u6b21\u521b\u5efa\u8ba2\u5355\u65f6&#xff0c;\u72ec\u7acb\u751f\u6210\u4e00\u4e2a\u968f\u673a\u5b57\u7b26\u4e32<\/li>\n<li>\u5728\u6570\u636e\u5e93\u4e2d\u989d\u5916\u5b58\u4e00\u4e2a\u5b57\u6bb5&#xff1a;public_id VARCHAR(32) UNIQUE<\/li>\n<li>\u67e5\u8be2\u65f6&#xff1a;\u7528 public_id \u4f5c\u4e3a\u67e5\u8be2\u6761\u4ef6&#xff08;\u9700\u5728\u8be5\u5b57\u6bb5\u4e0a\u5efa\u552f\u4e00\u7d22\u5f15&#xff09;<\/li>\n<\/ul>\n<h5>\u65b9\u6848 B&#xff1a;HMAC &#043; \u622a\u65ad&#xff08;\u4f2a\u968f\u673a\u4f46\u786e\u5b9a\u6027&#xff09;<\/h5>\n<p># \u4f7f\u7528\u5bc6\u94a5\u5bf9 internal_id \u505a HMAC&#xff0c;\u518d Base62 \u7f16\u7801\u53d6\u524d8\u4f4d<br \/>\nkey &#061; b&#034;your-secret-key&#034; h &#061; hmac.new(key, str(internal_id).encode(), &#039;sha256&#039;).digest()<br \/>\npublic_id &#061; &#034;ord_&#034; &#043; base62_encode(int.from_bytes(h[:6], &#039;big&#039;))[:8]<\/p>\n<ul>\n<li>\u76f8\u540c internal_id \u603b\u662f\u751f\u6210\u76f8\u540c public_id&#xff08;\u786e\u5b9a\u6027&#xff09;<\/li>\n<li>\u4f46\u65e0\u6cd5\u4ece public_id \u53cd\u63a8 internal_id&#xff08;\u56e0\u4e3a HMAC \u4e0d\u53ef\u9006 &#043; \u622a\u65ad\u4fe1\u606f\u4e22\u5931&#xff09;<\/li>\n<li>\u4ecd\u9700\u5b58\u50a8 public_id \u5b57\u6bb5&#xff08;\u56e0\u4e3a\u65e0\u6cd5\u5b9e\u65f6\u53cd\u7b97&#xff09;<\/li>\n<\/ul>\n<p>\u6ce8\u610f&#xff1a;\u5373\u4f7f\u4f7f\u7528 HMAC&#xff0c;\u5982\u679c\u622a\u65ad\u592a\u77ed&#xff08;\u5982\u53ea\u53d6 4 \u5b57\u7b26&#xff09;&#xff0c;\u53ef\u80fd\u6709\u78b0\u649e\u98ce\u9669\u3002\u4e00\u822c\u5efa\u8bae \u22658 \u5b57\u7b26\u3002<\/p>\n<p>\u4f18\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u771f\u6b63\u4e0d\u53ef\u9884\u6d4b&#xff0c;\u9632\u6b62 ID \u904d\u5386\u548c\u4e1a\u52a1\u6570\u636e\u63a8\u65ad<\/li>\n<li>\u7b26\u5408\u5b89\u5168\u6700\u4f73\u5b9e\u8df5&#xff08;OWASP \u63a8\u8350&#xff09;<\/li>\n<\/ul>\n<p>\u7f3a\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u9700\u8981\u989d\u5916\u5b58\u50a8 public_id \u5b57\u6bb5<\/li>\n<li>\u9700\u8981\u5728 public_id \u4e0a\u5efa\u552f\u4e00\u7d22\u5f15&#xff08;\u589e\u52a0\u5199\u5f00\u9500\u548c\u5b58\u50a8&#xff09;<\/li>\n<li>\u67e5\u8be2\u8def\u5f84\u53d8\u957f&#xff08;\u4e0d\u80fd\u76f4\u63a5\u7528\u4e3b\u952e&#xff09;<\/li>\n<\/ul>\n<h2>\u603b\u7ed3<\/h2>\n<h3>\u7ecf\u9a8c\u4e4b\u8c08<\/h3>\n<ul>\n<li>\u9762\u5411\u516c\u7f51\u3001\u7528\u6237\u53ef\u89c1\u7684 ID \u2192 \u7528\u968f\u673a\u751f\u6210&#xff0c;\u5b58\u5b57\u6bb5&#xff0c;\u4e0d\u53ef\u9006&#xff08;\u5b89\u5168\u4f18\u5148&#xff09;<\/li>\n<li>\u5185\u90e8\u7cfb\u7edf\u3001API \u95f4\u8c03\u7528\u3001\u65e5\u5fd7\u8ffd\u8e2a \u2192 \u53ef\u7528 Base62 \u7f16\u7801 Snowflake \u6216\u8005 \u5355\u7eafSnowflake&#xff08;\u6548\u7387\u4f18\u5148&#xff09;<\/li>\n<\/ul>\n<p>\u5728 Java \u4e2d&#xff0c;\u6211\u4eec\u5e38\u7528 Long \u7c7b\u578b\u627f\u8f7d\u5206\u5e03\u5f0f ID&#xff0c;\u4f46\u5728 Go \u4e2d&#xff0c;\u7531\u4e8e int \u7684\u957f\u5ea6\u53d6\u51b3\u4e8e\u5e73\u53f0&#xff0c;\u901a\u5e38\u5efa\u8bae\u660e\u786e\u4f7f\u7528 int64\u3002\u53e6\u5916&#xff0c;\u4e00\u5b9a\u4e0d\u8981\u5fd8\u8bb0\u524d\u7aef\u7cbe\u5ea6\u95ee\u9898&#xff1a;JavaScript \u7684 Number \u7c7b\u578b\u6700\u5927\u53ea\u80fd\u5b89\u5168\u8868\u793a <span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\"><\/p>\n<p>         2<\/p>\n<p>         53<\/p>\n<p>        \u2212<\/p>\n<p>        1<\/p>\n<p>       2^{53} &#8211; 1<\/p>\n<p>    <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.8974em;vertical-align: -0.0833em\"><\/span><span class=\"mord\"><span class=\"mord\">2<\/span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.8141em\"><span class=\"\" style=\"top: -3.063em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">53<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mspace\" style=\"margin-right: 0.2222em\"><\/span><span class=\"mbin\">\u2212<\/span><span class=\"mspace\" style=\"margin-right: 0.2222em\"><\/span><\/span><span class=\"base\"><span class=\"strut\" style=\"height: 0.6444em\"><\/span><span class=\"mord\">1<\/span><\/span><\/span><\/span><\/span>&#xff0c;\u800c 64 \u4f4d ID \u6700\u5927\u662f <span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\"><\/p>\n<p>         2<\/p>\n<p>         63<\/p>\n<p>        \u2212<\/p>\n<p>        1<\/p>\n<p>       2^{63} &#8211; 1<\/p>\n<p>    <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.8974em;vertical-align: -0.0833em\"><\/span><span class=\"mord\"><span class=\"mord\">2<\/span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.8141em\"><span class=\"\" style=\"top: -3.063em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">63<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mspace\" style=\"margin-right: 0.2222em\"><\/span><span class=\"mbin\">\u2212<\/span><span class=\"mspace\" style=\"margin-right: 0.2222em\"><\/span><\/span><span class=\"base\"><span class=\"strut\" style=\"height: 0.6444em\"><\/span><span class=\"mord\">1<\/span><\/span><\/span><\/span><\/span>\u3002<\/p>\n<h3>\u6742\u8c08<\/h3>\n<p>\u4e86\u89e3\u5206\u5e03\u5f0f\u751f\u6210ID\u5bf9\u5206\u5e03\u5f0f\u4e8b\u52a1&#xff0c;\u5206\u5e93\u5206\u8868\u8fd9\u4e9b\u91cd\u70b9\u95ee\u9898\u90fd\u975e\u5e38\u91cd\u8981&#xff0c;\u800c\u4e14\u5176\u4e2d\u90fd\u6709\u5f88\u591a\u524d\u4eba\u8e29\u8fc7\u7684\u5751\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u4e0d\u540c\u4e1a\u52a1\u5bf9\u5206\u5e03\u5f0f\u751f\u6210ID\u7684\u9700\u6c42\u5ea6\u90fd\u4e0d\u540c&#xff0c;\u4e0d\u4e00\u5b9a\u8981\u6309\u7167\u6700\u4e25\u683c\u7684\u53bb\u5f04&#xff0c;\u6709\u65f6\u5019\u53ef\u80fd\u9002\u5f97\u5176\u53cd&#xff0c;\u6bd5\u7adf\u9002\u5408\u81ea\u5df1\u7684\u624d\u662f\u6700\u597d\u7684\u3002<\/p>\n<p>\u5982\u679c\u4f60\u89c9\u5f97\u8fd9\u7bc7\u6587\u7ae0\u7ed9\u4f60\u5e26\u6765\u4e86\u4e0d\u9519\u7684\u4f53\u611f&#xff0c;\u90a3\u5c31\u7ed9\u6211\u70b9\u8d5e&#043;\u6536\u85cf&#043;\u5173\u6ce8\u5427&#xff0c;\u8fd9\u662f\u6211\u66f4\u65b0\u7684\u6700\u5927\u52a8\u529b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u76ee\u5f55\u5f15\u8a00\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528\u81ea\u589e\u4e3b\u952e&#xff1f;\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u56f0\u96be\u5b89\u5168\u4e0e\u4e1a\u52a1\u98ce\u9669**\u66b4\u9732\u4e1a\u52a1\u89c4\u6a21****\u5b89\u5168\u9690\u60a3&#xff1a;ID \u904d\u5386\u653b\u51fb&#xff08;IDOR&#xff09;****\u5f71\u54cd A\/B \u6d4b\u8bd5\u6216\u7070\u5ea6\u53d1\u5e03**\u5206\u5e03\u5f0f\u4e3b\u952e\u7684\u6838\u5fc3\u8981\u6c42\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848: \u5185\u5916\u5206\u79bb\u5185\u90e8\u4e3b\u952eID\u6570\u636e\u5e93 Seq \u8868\u65b9\u6848 (\u4f20\u7edf\u6a21\u5f0f)UUID(Universally Unique Identifier)Redis INCRSnowflake &#8211; \u96ea\u82b1\u7b97\u6cd5&#xff08;\u91cd\u70b9&amp;#xff09<\/p>\n","protected":false},"author":2,"featured_media":61807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[664,292,227,188,442,176],"topic":[],"class_list":["post-61808","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-664","tag-292","tag-227","tag-188","tag-442","tag-176"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/61808.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u76ee\u5f55\u5f15\u8a00\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528\u81ea\u589e\u4e3b\u952e&#xff1f;\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u56f0\u96be\u5b89\u5168\u4e0e\u4e1a\u52a1\u98ce\u9669**\u66b4\u9732\u4e1a\u52a1\u89c4\u6a21****\u5b89\u5168\u9690\u60a3&#xff1a;ID \u904d\u5386\u653b\u51fb&#xff08;IDOR&#xff09;****\u5f71\u54cd A\/B \u6d4b\u8bd5\u6216\u7070\u5ea6\u53d1\u5e03**\u5206\u5e03\u5f0f\u4e3b\u952e\u7684\u6838\u5fc3\u8981\u6c42\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848: \u5185\u5916\u5206\u79bb\u5185\u90e8\u4e3b\u952eID\u6570\u636e\u5e93 Seq \u8868\u65b9\u6848 (\u4f20\u7edf\u6a21\u5f0f)UUID(Universally Unique Identifier)Redis INCRSnowflake - \u96ea\u82b1\u7b97\u6cd5&#xff08;\u91cd\u70b9&amp;#xff09\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/61808.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-18T08:25:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260118082546-696c990aa49b5.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/61808.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/61808.html\",\"name\":\"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-18T08:25:47+00:00\",\"dateModified\":\"2026-01-18T08:25:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/61808.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/61808.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/61808.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/61808.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u76ee\u5f55\u5f15\u8a00\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528\u81ea\u589e\u4e3b\u952e&#xff1f;\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u7684\u56f0\u96be\u5b89\u5168\u4e0e\u4e1a\u52a1\u98ce\u9669**\u66b4\u9732\u4e1a\u52a1\u89c4\u6a21****\u5b89\u5168\u9690\u60a3&#xff1a;ID \u904d\u5386\u653b\u51fb&#xff08;IDOR&#xff09;****\u5f71\u54cd A\/B \u6d4b\u8bd5\u6216\u7070\u5ea6\u53d1\u5e03**\u5206\u5e03\u5f0f\u4e3b\u952e\u7684\u6838\u5fc3\u8981\u6c42\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848: \u5185\u5916\u5206\u79bb\u5185\u90e8\u4e3b\u952eID\u6570\u636e\u5e93 Seq \u8868\u65b9\u6848 (\u4f20\u7edf\u6a21\u5f0f)UUID(Universally Unique Identifier)Redis INCRSnowflake - \u96ea\u82b1\u7b97\u6cd5&#xff08;\u91cd\u70b9&amp;#xff09","og_url":"https:\/\/www.wsisp.com\/helps\/61808.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-18T08:25:47+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260118082546-696c990aa49b5.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/61808.html","url":"https:\/\/www.wsisp.com\/helps\/61808.html","name":"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-18T08:25:47+00:00","dateModified":"2026-01-18T08:25:47+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/61808.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/61808.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/61808.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4e00\u7ad9\u5f0f\u4e86\u89e3\u5168\u5c40\u5206\u5e03\u5f0f\u751f\u6210ID\u65b9\u6848"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/61808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=61808"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/61808\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/61807"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=61808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=61808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=61808"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=61808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}