|
|
|
|
|
by tijsvd
1290 days ago
|
|
Take incrementing int32. Extend to 64 bits. Multiply by large prime number (e.g. fnv32 prime). Mod 1 million. Add 1 million. End up with random looking, 7 digits, nicely sequenced, 32 bit integers. Write an exhaustive test to verify. When near 1 million users (yagni), reset sequence and do the same with 10 million (or one billion). Doesn't solve the upside of 128-bit random numbers (ala uuid): the ability to generate remotely and expect no collision. |
|
I don’t see how remote generation is an upside. If you’re using UUID as a database key, you’re hitting the DB anyway, so it doesn’t save a trip to the DB.
There are plenty of uses for UUID like peer-to-peer apps where that makes sense, but the article is talking about database keys.