💎多语言实现,高性能生成唯一数字ID。 💎优化的雪花算法(SnowFlake)——雪花漂移算法,在缩短ID长度的同时,具备极高瞬时并发处理能力(50W/0.1s)。 💎原生支持 C#/Java/Go/Rust/C/JavaScript/TypeScript/Python/Pascal 多语言,提供其它适用于其它语言的多线程安全调用动态库(FFI)。💎支持容器环境自动扩容(自动注册 WorkerId ),单机或分布式唯一IdGenerator。💎顶尖优化,超强效能。
MIT License
3
ID5W/s
5W/s50W/sSeqBitLength=10
50W/s500W/sSeqBitLength=12
SeqBitLength ID
ID
k8s WorkerIdID
C#/Java/Go/C/Rust/Python/Node.js/PHP(C)/SQL/ FFI
ID20228
SelectInsert Update
js Number Long String
Guid
5010W/s
redis IDID
100
ID
ID
50 js Number
2-50.1508i7
1ID
IDID5000
k8s WorkerId redis
(101000)
5K | 5W | 50W | |
---|---|---|---|
0.0045s | 0.053s | 0.556s | |
0.0015s | 0.012s | 0.113s |
500W/s~3000W/s8i7
ID
ID
ID 8ID
129053495681099 (115)
387750301904971 (315)
646093214093387 (515)
1292658282840139 (1016)
9007199254740992 (70 js Number 16)
165399880288699493 (1000118)
ID js Number 1%-10%
js Number 90071992547409925W+/0.01s64 WorkerId6bit70 js Number Max
1 WorkerIdBitLength SeqBitLengthID2ID2
ID long648
ID 71000
1024 ID 4480
4096 ID 1120
WorkerIdBitLength WorkerId 6 [1, 19] ushort (uint16) 16 short (int16)15
WorkerId**** **** DataCenterId ****WorkerIdBitLength63 2^WorkerIdBitLength-1 65535 32767 WorkerIdBitLength ****WorkerId redis WorkerId Tools\AutoRegisterWorkerId
**** WorkerId
SeqBitLength6 [3, 21]4ID5W65W50W10WorkerIdBitLength + SeqBitLength 22
MinSeqNumber5 [5, MaxSeqNumber]50-41-40
MaxSeqNumber [MinSeqNumber, 2^SeqBitLength-1]02^SeqBitLength-10WorkerIdID
BaseTime2020.NETDatetTimeIDID
DataCenterIdIDID0
DataCenterIdBitLengthID0
TimestampType0-1-0
1 IDID
2 WorkerId WorkerId
3 WorkerId WorkerId
4 Exception catch
5 IdGeneratorOptions
6 Method=2Method=1
7
8 WorkerId WorkerId WorkerId
9
IdGeneratorOptions
1.BaseTime IDID[ BaseTime]
WorkerIdBitLength SeqBitLength ID [ **** xxxBitLength ]
WorkerIdBitLength SeqBitLength xxxBitLength [**** BitLength ]
4.3
IDWorkerIdWorkerIdID
go k8s redis WorkerId
redisWorkerId WorkerId
WorkerId
IDID
https://github.com/yitter/IdGenerator/blob/master/Tools/AutoRegisterWorkerId/regprocess.jpg
/Go/source/regworkerid/reghelper.go
https://github.com/yitter/IdGenerator/releases/download/v1.3.3/workeridgo_lib_v1.3.3.zip
// WorkerId
// address: Redis127.0.0.1:6379/127.0.0.1:26380,127.0.0.1:26381,127.0.0.1:26382
// password: Redis
// db: Redis1
// sentinelMasterName: Redis mymaster
// minWorkerId: WorkerId 30
// maxWorkerId: WorkerId 63
// lifeTimeSeconds: WorkerId315
extern GoInt32 RegisterOne(char* server, char* password, GoInt32 db, char* sentinelMasterName, GoInt32 minWorkerId, GoInt32 maxWorkerId, GoInt32 lifeTimeSeconds);
// WorkerId
extern void UnRegister();
github | |
---|---|
C# | |
Java | |
Go | |
Rust | |
Python | |
C | |
C (PHP) | |
Delphi (Pascal) | |
JavaScript | |
TypeScript | |
V | |
D |
https://github.com/yitter/IdGenerator
QQ646049993