Unique key generation

后端 未结 13 2193
一个人的身影
一个人的身影 2020-12-03 05:53

I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key.

I have done the following:

strtolower(substr(crypt(tim         


        
13条回答
  •  离开以前
    2020-12-03 06:27

    You may be interested in this article which deals with the same issue: GUIDs are globally unique, but substrings of GUIDs aren't.

    The goal of this algorithm is to use the combination of time and location ("space-time coordinates" for the relativity geeks out there) as the uniqueness key. However, timekeeping is not perfect, so there's a possibility that, for example, two GUIDs are generated in rapid succession from the same machine, so close to each other in time that the timestamp would be the same. That's where the uniquifier comes in.

提交回复
热议问题