friendly_id and parallel processes
I've been using friendly_id4 for a while now and noticed that it doesn't have a guard to ensure that processes to not race to generate the next slug when collisions occur.
To that end, I submitted a patch that should clean up their internal API, and make it simper to override. I've written my own driver which uses Redis to store the unique key, looking it up the first time using the friendly_id built-in mechanism.
In this post I share my code, and explore some of the reasons for the design, as well as explaining what causes the processes to race, and how we can guard against that.