Creating unique identifiers is tricky. More if you can’t have locking or a global service which doles out numbers in a sequence.
Sure there is the 128-bit UUID that should almost always generate a unique identifiers with a tiny probability of clashing – the odds of generating duplicate UUID values are like finding two grains of sand having the same shape. However these values are large and difficult to handle unless converted to string. Moreover there is no ordering guaranteed on those randomly-created UUID values.
What if I say that you can create unique identifiers that are ordered, unsynchronized, yet stay within a 64-bit integer data type? Unlike UUID types, these values can be stored and processed efficiently by many programming languages without needing stringification.
I’ve covered this in a lightning talk in iOS Conference Singapore on 19 January 2019.
Special thanks to Engineers.SG for capturing the video and publishing it.
0 thoughts on “Swift Snowflake ID Generator”
You must log in to post a comment.