An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# snowflake4j
A simple implementation of the Twitter snowflake in Java, using the Racket epoch.

## Installing
### Maven

Add this to your repositories:
```xml

dmrail-nexus
https://nexus.dmrail.games/repository/maven-public/

```

And add this to your dependencies:
```xml

tk.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
}
}
```