https://github.com/lizainslie/snowflake4j
A simple implementation of the Twitter snowflake in Java, using the Racket epoch.
https://github.com/lizainslie/snowflake4j
java snowflake
Last synced: 8 months ago
JSON representation
A simple implementation of the Twitter snowflake in Java, using the Racket epoch.
- Host: GitHub
- URL: https://github.com/lizainslie/snowflake4j
- Owner: LizAinslie
- Created: 2019-09-30T23:40:47.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-01T15:01:55.000Z (about 6 years ago)
- Last Synced: 2024-12-27T20:33:47.990Z (9 months ago)
- Topics: java, snowflake
- Language: Java
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# snowflake4j
A simple implementation of the Twitter snowflake in Java, using the Racket epoch.## Installing
### MavenAdd this to your repositories:
```xmldmrail-nexus
https://nexus.dmrail.games/repository/maven-public/```
And add this to your dependencies:
```xmltk.racket.utils
snowflake
0.0.1```
Versions can be found in the releases or at [the Nexus repo](https://nexus.dmrail.games/#browse/browse:maven-public).
## Usage
Use the `SnowflakeGenerator` class as a singleton, like:```java
public class Main {
private static SnowflakeGenerator snowflakeGen = new SnowflakeGenerator();
public static void main(String[] args) {
for (i = 0; i < 10; i++) System.out.println(snowflakeGen.nextId()); // Generates and prints a new snowflake
}
}
```