Skip to content

一个分布式ID生成算法 .NET Standard = 1.1

License

Notifications You must be signed in to change notification settings

Corual/IDWorker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IDWorker

一个分布式ID生成算法

.NET Standard

.NET Standard = 1.1

SnowflakeIdWorker用法

//获取一个开始时间戳
long startTimestmap = (long)(DateTime.UtcNow.AddDays(-20) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;

//使用时间戳构造
IIDWorker iDWorker = new SnowflakeIdWorker(startTimestmap, 10, 1);

//或者直接使用DateTime构造
//IIDWorker iDWorker = new SnowflakeIdWorker(DateTime.AddDays(-20), 10, 1);

//获得Id
long id = iDWorker.NextId();

About

一个分布式ID生成算法 .NET Standard = 1.1

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages