//
you're reading...

Programming

Swift Snowflake ID Generator

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.



Do you enjoy this post? Enter your e-mail address in the form below to receive:

  • A cheat sheet on how to pass App Review Guideline 4.2 “Minimum Functionality”.
  • Notifications of new articles as soon as they are published.
  • Occasional tips and updates about my work.

You can unsubscribe any time and I won’t share your e-mail to any third party.

* indicates required

Discussion

No comments yet.

Leave a Reply