Ruby UUID and uniqueness, for an ID -


I need a 6 letter alphanumeric ID to be used in my Rail app, which will be presented to system users and In my system unique to all object instances, I do not expect more than a few thousand object instances, so 6 characters are really too big for me.

At this time I am using the UIIdTools gem to generate UUID in my Rail app. Which of the methods of UUIDTools generation should I use, and as a result, the end of the UUID should take 6 letters to guarantee specificity?

For example, if I generate ef1cf087-95c9-4868 -bd95-cea950a52b58 , should I follow it from ef1cf0 , or behind Would you like to use a52b58 from the corner?

.. As a side note / question: am I going to go about this wrong thing? Is there a better way?

No way UUID is considered unique because it is too long and practical to generate the same UUID The form is impossible. If you trim it in 6 letters, then you increase the fragility of the duplicate. You must either use a mounting ID or full UUID.

Only deterministic generation ( id (x + 1) = id (x) + 1 ) can guarantee exclusivity. UUID does not guarantee and less than 6 characters guarantee less.

There is another option, to create an ID generation service, it will have single method getNewId and will keep knowledge which will be prepared to provide unique IDs. (Simple Case - Counter)

Comments