I am new to ruby on rails. i want to generate unique token for each client. i can generate unique token with SecureRandom.hex(6),but then i have to check wheter this value exists in the database and it is very time consuming if the database is very large. i can append the current time to secureadnom.hex(6) function but then again if the rails processes the two request at the same time then there is no guaranty of uniqueness.
Can someone tell me the best way to generate unique token without hitting query to database level.
Thanks,
Aucun commentaire:
Enregistrer un commentaire