What is ULID?
ULID stands for Universally Unique Lexicographically Sortable Identifier,
they are composed of a timestamp and a random component called entropy, which are combined to create a unique identifier.
How?
The timestamp component is a 48-bit integer that represents the number of milliseconds since midnight on January 1, 1970, UTC. The random component is called as entropy is a 80-bit integer that is generated using a cryptographically secure random number generator.
01GXNPWRFH0338V2CSNSV8N3NY
01GXNPWRFH 0338V2CSNSV8N3NY
|----------| |----------------|
Timestamp Entropy
48bits 80bitsWhy?
We already have UUIDs Universally Unique Identifiers, the main drawback of UUID is they are not sortable, bulky and have lesser randomness.
There is a gem https://github.com/abachman/ulid-ruby, which has a very good readme.