Skip to content

Commit 2345599

Browse files
committed
update spec to provide stricter guidlines on zuid generation
1 parent 2ef81b2 commit 2345599

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,50 @@
77
Example ZUID:
88

99
```
10-
1-1b123a2f0-qw2n4
10+
structure: component1-component2-component3
11+
lengths: maxlen5-maxlen10-maxlen35
12+
13+
e.g. 1-1b123a2f0-qw2n4
1114
```
1215

1316
## Component 1: Entity Prefix
1417

15-
* Component 1 is an integer (ultimately stored as part of a string)
16-
* There is no direct limit on length of this component other than the total ZUID length of 50 characters. However, it is pretty unlikely it will exceed 5 characters.
18+
* Is an integer (ultimately stored as part of a string)
19+
* Limited to 5 characters.
1720

18-
These string integers are static representations of specific entity types and are provided in each library as some form of constant.
21+
*These string integers are static representations of specific entity types and are provided in each library as some form of constant.*
1922

2023
## Component 2: Time Encoded as a String
2124

22-
* This is encoded as hexidecimal like `a3f13d`
23-
* We substract `1420070400` to shorten the hash slightly
24-
* `1420070400` is January 1st, 2015 (in seconds), before the first zuid was generated
25-
* There is also no direct limit on the length of this component (other than the total ZUID length).
26-
25+
* __Can NOT be seconds based measurement.__ This is not precise enough for unique hashes.
26+
* Must be 10 characters
27+
* Encoded as hexidecimal string like `d0f1b38ad3`
2728

2829
Example:
2930

3031
```
3132
Date (and time):
32-
Wed Apr 12 2017 14:53:06 GMT-0700 (PDT)
33+
2018-03-23 14:36:18.643025 -0700 PDT m=+0.000811554
3334
34-
In seconds:
35-
1492033987
35+
In nano seconds:
36+
1521840978643025000
3637
3738
As hex:
38-
"58eea1c3"
39+
"d0f1b38ad3"
3940
```
4041

4142
## Component 3: A Random Alphanumeric String
4243

4344
* This is a random alphanumeric string.
44-
* It is by default generated as 5 characters long.
45-
* It can be generated as up to 15 characters if more possibilities as desired
46-
* It randomly selects from the characters `bcdfghjklmnpqrstvwxz0123456789`
45+
* Minimum of 6 character length.
46+
* Maximum of 35 characters length.
47+
* It randomly selects from the character set `bcdfghjklmnpqrstvwxz0123456789`
4748
* It does not use vowels to avoid forming words in IDs
4849

4950

5051
# Libraries
5152

52-
* [zuid-js](https://github.com/zesty-io/zuid-specification)
53+
* [zuid-js](https://github.com/zesty-io/zuid-js)
5354
* [zuid-php](https://github.com/zesty-io/zuid-php)
5455
* [zuid-mysql](https://github.com/zesty-io/zuid-mysql)
5556

0 commit comments

Comments
 (0)