I am looking for the most reliable way to generate unique ids for a project where users can post content without getting duplicates. When the post is submitted I would like to generate a unique id for it to be referenced back to. Such as when loaded from a shared link which might look like
example.com/post/e8a42f290fd853daa666aeaefa607f42
Except I rather have shorter links.
The ids will probably be a combination of a user's username and the current time.
Although there are similar questions I haven't found one that provide answers that I think are best, most suggest using md5 then trim it down, except that would higher the chances of the same string being generated.
Edit:
I am not using auto increment because it will become harder to scale later on.