| Recommend this page to a friend! |
| Packages of A. B. M. Mahmudul Hasan | UID (UUID, ULID, Snowflake, Sonyflake, Nano, CUID, KSUID, XID, TBSL) | TBSL.md | Download |
|
|||||||||||||||||||||
TBSL SpecificationTBSL is a project-specific, time-based, lexicographically sortable identifier used by
This document defines the canonical TBSL text format and the generation rules used by this package. Canonical FormatA canonical TBSL identifier is exactly 20 uppercase hexadecimal characters:
The canonical string represents 10 bytes, or 80 bits, of data. Lowercase hexadecimal and non-hexadecimal characters are not canonical TBSL values. Field LayoutCharacter positions are 1-based. | Characters | Length | Field | Description |
|:--|--:|:--|:--|
| 1-15 | 15 hex chars | Time-machine payload | Uppercase hexadecimal encoding of the decimal payload The decimal payload is composed as follows: | Decimal digits | Length | Field | Description |
|:--|--:|:--|:--|
| 1-10 | 10 digits | Unix seconds | Seconds since the Unix epoch. |
| 11-16 | 6 digits | Microseconds | Microsecond fraction of the current second. |
| 17-18 | 2 digits | Machine ID | Machine identifier from GenerationGeneration accepts:
The generator:
Sequence providers should keep returned sequence values within the 20-bit suffix
range, ParsingTo parse a canonical TBSL value:
The suffix is intentionally opaque. It is not needed to recover the timestamp or machine ID. OrderingCanonical TBSL strings sort lexicographically by their time-machine payload first. This preserves chronological ordering for generated IDs as long as system clocks move forward. For IDs generated within the same microsecond and machine ID:
If the clock moves backward, the implementation either waits for the next usable time sequence or throws, depending on the configured clock-backward policy. EncodingsThe canonical representation is uppercase hexadecimal. The package can also convert canonical TBSL values to and from:
Alternate-base encodings are transport encodings only. They do not replace the canonical 20-character uppercase hexadecimal TBSL string. Limits
|