lundi 21 décembre 2015

Generating short unique reference id with PHP uniqid function

My objective is to create a unique id attach it to a record and store it in the DB. The id should be alpha - numeric and short. I don not want to use the auto increment way of generating ids as this ID is going to be attached to end of a url so I don't want it to be guessable. After some research I have decided to use uniqid() as i understood that its generated based on time.

My worry is will it be unique across the system and is there a chance for the id to become repeated if i am going scale my system using multiple servers and clustering??

i don't want to do a duplicate check before inserting the value into the DB as this can affect the performance over time as records increase.

I am using Larvel framework. Can anyone suggest any other solution to tackle this problem. I am new to laravel.

Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire