https://github.com/downgoon/snowflake
java edition of [Twitter Snowflake](https://github.com/twitter/snowflake), a network service for generating unique ID numbers at high scale with some simple guarantees.
https://github.com/downgoon/snowflake
auto-increment id-generator sequence snowflake unique-id uuid
Last synced: 10 months ago
JSON representation
java edition of [Twitter Snowflake](https://github.com/twitter/snowflake), a network service for generating unique ID numbers at high scale with some simple guarantees.
- Host: GitHub
- URL: https://github.com/downgoon/snowflake
- Owner: downgoon
- Created: 2017-09-16T02:17:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-12T07:34:49.000Z (over 7 years ago)
- Last Synced: 2025-05-09T01:46:28.414Z (10 months ago)
- Topics: auto-increment, id-generator, sequence, snowflake, unique-id, uuid
- Language: Java
- Size: 305 KB
- Stars: 122
- Watchers: 2
- Forks: 45
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-java - Snowflake
README
# Snowflake
java edition of [Twitter Snowflake](https://github.com/twitter/snowflake), a network service for generating unique ID numbers at high scale with some simple guarantees.
## QuickStart
- import maven dependency
``` xml
xyz.downgoon
snowflake
1.0.0
```
- sample code
``` java
// 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](src/test/java/xyz/downgoon/snowflake/SnowflakeDemo2.java).
## snowflake tutorial
- [snowflake tutorial](docs/SnowflakeTutorial_zh_CN.md):中文教程