Skip to content

Files

Latest commit

974f199 · Sep 18, 2017

History

History
This branch is up to date with downgoon/snowflake:master.

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 16, 2017
Sep 16, 2017
Sep 18, 2017

Snowflake

java edition of Twitter Snowflake, a network service for generating unique ID numbers at high scale with some simple guarantees.

QuickStart

  • import maven dependency
<dependency>
  <groupId>xyz.downgoon</groupId>
  <artifactId>snowflake</artifactId>
  <version>1.0.0</version>
</dependency>
  • sample code
// datacenter: 2; workerId: 5
Snowflake snowflake = new Snowflake(2, 5);
long id1 = snowflake.nextId();
long id2 = snowflake.nextId();

snowflake.formatId(id1);

for more details, please read SnowflakeDemo2.java.

snowflake tutorial