Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Umm.. But you don't need distributed generation, do you? I think a db sequence would be a nice way to get unique values for your formatted string seed [instead of the timestamp]
-
GTom7186y@netikras
Friiick, I forgot the KISS again.
You are right.
EDIT: After reading your comment, I went from red to green before I fully facepalmed myself, I don't know why but I HAVE HAD tried seeding it with single n++ number which obviously worked but I was in this illusion that I HAVE TO use timestamp somehow. -
zotigapo7616ySo bssically you are doing tiny url.
I feel like you may get lot of collisions.
You need re design your architecture for tiny url. Its not that simple at app level to generate tiny url. -
mindev5366y@zotigapo why do you think it's not easy? There's almost nothing hard that I can see about it.
-
mindev5366yIf you are trying to make a URL shortener, look into base62 conversion. At least that's what I used for mine.
Edit: After 100k records it uses 3 characters as an ID
Related Rants
How do you approach generating "random" unique numbers/strings ? Exactly, when you have to be sure the generated stuff is unique overtime? Eg. as few collisions in future as possible.
Now I don't mean UUIDs but when there is a functionality that needs some length defined, symbol specific and definitely unique data, every time it does it's stuff.
TLDR STORY: Generating 8 digits long numbers so they are (deterministically - wink wink) unique is hard but Format Preserving Encryption saves the day. (for me)
FULL STORY:
I had to deal with both strings and codes today.
One was to generate shortlink word for url, luckily found a library that does exactly this. (Hashids)
BUT generating 8 digits long, somewhat random number was harder then I thought, found out on SO something like "sha256(seed) => bytes => ascii/numbers mangling" but that had a lot of collisions because of how the hash got mangled to actually output numbers and also to fit the length.
After some hours I stumbled upon Format Preserving encryption (pyffx) and man it did what I wanted and it had max 2 collisions in 100k values. Still the solution with this feels hacky af. (encrypting straddled unix timestamp with lots of decimals)
question
encryption
deterministic
unique
hashes
strings
codes