PUGX / shortid-php

An implementation of ShortId in PHP
MIT License
51 stars 7 forks source link

Unique id with time #8

Closed clementbirkle closed 6 years ago

clementbirkle commented 6 years ago

Hello, apparently this library is a port of https://github.com/dylang/shortid

The shortid original library create ids with the time to ensure unique ids. I did't see anything similar in this library.

See more here: https://github.com/dylang/shortid/blob/master/lib/build.js

How this library can ensure a unique id ?

garak commented 6 years ago

There's no ensured uniqueness. Time doesn't help about that, since you can't assume that IDs are generated in different times. The real question is the probability of clashing IDs. As already mentioned in #7, you can decrease the chance of clashes by increasing the length of your Shortid.

clementbirkle commented 6 years ago

Thank you for your fast response. I thought that the time help to reduce the possibility of collision but apparently not :/