There are at least the following requirements
- is hashed and random, at least not guessed sequence rules
- is never repeated, if the build once to verify the existence, that efficiency is not too low?
Reply content:
There are at least the following requirements
- is hashed and random, at least not guessed sequence rules
- is never repeated, if the build once to verify the existence, that efficiency is not too low?
It is recommended to refer to MongoDB's objectid generation mechanism. Objectid altogether 12 bytes
- A 4-byte timestamp, placed in the first section, allows the Objectid to "approximate" the chronological order, guaranteeing that the IDs generated for different seconds must not be duplicated
- 3-byte machine ID, by default the machine's various basic information hash, to ensure that the same second machine generated ID must not be duplicated
- A 2-byte process number that guarantees that the same machine will generate IDs of different processes in the same second.
- 3 bytes of self-increment, in the same second self-increment, to ensure that the same second machine in the same process generated 16,777,216 ID must not be duplicated
You can use the UUID, if you want to change the number, then do the conversion.
Maybe the numbers will be bigger, you have to define your own rules and zoom out.