Home

Awesome

sandflake-java

Implementation of Sandflake IDs inspired by Twitter's Snowflake IDs.

This is java port of the Go library https://github.com/celrenheit/sandflake

Features

Design

128bit IDs:

Usage

For now refer to the test:

TimeBasedGenerator generator = new TimeBasedGenerator();
SandflakeID id = generator.next();
SandflakeID next = generator.next();

assertThat(id).isNotEqualTo(next);
assertThat(SandflakeID.encode(id)).isNotEqualTo(SandflakeID.encode(next));

Acknowledgements

To be compatible with the base32 alphabet used in https://github.com/celrenheit/sandflake, I have copied the excellent base32 encoders from Google Guava project to be able to change the alphabet used and still be compatible with the Go library.

Thanks to https://github.com/celrenheit/sandflake for the implementation this port is based on.