Skip to content

Distributed unique ID generator inspired by Twitter;s Snowflake

License

Notifications You must be signed in to change notification settings

Shiroechi/ShiroFlake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShiroFlake

ShiroFlake is a distributed unique ID generator inspired by on Twitter's Snowflake

ShiroFlake by default using same parameter that used in Twitter's Snowflake.

A ShiroFlake ID is composed of

41 bits for time in units
12 bits for a machine id
10 bits for a sequence number

But you can set the unsigned parameter to true at initialization the generator to use full 64 bit.

var generator = new ShiroFlakeGenerator(
    1, // machine id
    unsigned: true);

As a result, ShiroFlake has the following advantages:

  • The lifetime (~139 years if unsigned is true) is longer than that of Snowflake (69 years)
  • It can work in more distributed machines (2^12) than Snowflake (2^10)

About

Distributed unique ID generator inspired by Twitter;s Snowflake

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages