This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 使用 snowflake 算法生成递增的分布式唯一ID. | |
| * 该算法支持 15 条业务线,4 个数据中心,每个数据中心最多 128 台机器,每台机器每毫秒可生成 4096 个不重复ID. | |
| */ | |
| class Snowflake | |
| { | |
| const SEQUENCE_BITS = 12; | |
| const MILLISECOND_BITS = 39; | |
| const BUSINESS_ID_BITS = 4; | |
| const DATA_CENTER_ID_BITS = 2; |
NewerOlder