Generating unque IDs: an easy and reliable way -
antirez 14 hours ago. 15207 views. Two days ago Mike Malone published an interesting post on Medium about the V8 implementation of Math.random(), and how weak is the quality of the PRNG used: http://bit.ly/1SPDraN . The post was one of the top news on Hacker News toady. It's pretty clear and informative from the point of view of how Math.random() si broken and how should be fixed, so I've nothing to add to the matter itself. But since the author discovered the weakness of the PRNG in the context of generating large probably-non-colliding IDs, I want to share with you an alternative that I used multiple times in the past, which is fast and extremely reliable. The problem of unique IDs - - - So, in theory, if you want to generate unique IDs you need to store some state that makes sure an ID is never repeated. In the trivial case you may use just a simple counter. However the previous ID generated must be stored in a consistent way. In case of restart of the system,
Read full article from Generating unque IDs: an easy and reliable way -
No comments:
Post a Comment