I did some benchmarking of various Redis locking gems years ago.
You can improve your gem in two ways:
Note: I wrote and sell my own commercial version as part of Sidekiq Enterprise.
Ah! interesting. Thanks for the feedback. Will look at incorporating.
Anecdotes about stolen backpacks in high school are cute, but how is this different from the many other redis-backed locks on rubygems.org, or at least the most popular, redlock?
Redlock is distributed. You use multiple Redi’ to decide who gets the lock, similar to Paxos or Raft. Most people don’t need this complexity.
Simple mutexes like this one use a single Redis and aren’t fault tolerant if Redis dies.
Thanks Mike, that’s exactly what the decision was here. I needed a simple mutex to reach for, didn’t want to manage multiple Redi for this. Wasn’t something I was worried about it the single Redis went down, etc. So made something I thought was easy to grok and maintain.
I wrote one of these many years ago to help with distributed synchronization. uncomplicated_mutex