SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier
SCRU64 ID offers compact, time-ordered unique identifiers generated by
distributed nodes. SCRU64 has the following features:
- ~62-bit non-negative integer storable as signed/unsigned 64-bit integer
- Sortable by generation time (as integer and as text)
- 12-digit case-insensitive textual representation (Base36)
- ~38-bit Unix epoch-based timestamp that ensures useful life until year 4261
- Variable-length node/machine ID and counter fields that share 24 bits
globalThis.SCRU64_NODE_SPEC = "42/8";
import { scru64Sync, scru64StringSync } from "scru64";
const x = scru64Sync();
console.log(String(x));
console.log(x.toBigInt());
console.log(scru64StringSync());
See SCRU64 Specification for details.
SCRU64's uniqueness is realm-specific, i.e., dependent on the centralized
assignment of node ID to each generator. If you need decentralized, globally
unique time-ordered identifiers, consider SCRU128.
License
Licensed under the Apache License, Version 2.0.
See also