i hate how long it is
something like youtube URLs but guaranteed to be without duplicates
i hate how long it is
something like youtube URLs but guaranteed to be without duplicates
Maybe one way is to split up a random assignment space and assign to each distributed node, but that would be more complex.
Then just encode it in a format of your choosing. Youtube uses a modified base64 encoding (no padding, and + and / are replaced by - and _). And youtube video ids seem to also be 64 bits, just like xtea output.
If you're distributed, look into vector clocks[1] or snowflake[2][3]
[1] https://en.wikipedia.org/wiki/Vector_clock
[2] https://github.com/twitter-archive/snowflake/tree/snowflake-...
You might think your "Uber, but for short term giraffe rental" startup needs that sort of guarantee in the investor demo prototype, but it doesn't. Just use an auto increment in Postgres or MySQL (or an integer primary key column in SQLite). If you fool those investors into pouring the money pipe over you, your first real technical/senior engineer hire is gonna throw all the code you have running on your laptop away anyway.
Maybe someone at Meta sat down once and figured "we have 4 billion users, each of who on average has 3 cats that they take a dozen picture of every day, so about 150 billion cat pictures per day. So if we name them using uuids we're still good for almost 50 thousand years before we have a 50% chance of displaying a pic of Fluffy when we should have displayed a pic of Mr Whiskers". Then they promptly ignored the problem (or fixed Zack's code that was using php's hash("md2", $query['catname']) ).
But yes, if you're just using them as primary keys in a database you're probably fine with auto increment for most use cases.