According to [the documentation](https://redis.io/commands/setnx), you shouldn't use SETNX for locking and instead use the [Redlock algorithm as described here](https://redis.io/topics/distlock). Since there's already a [redlock-rb](https://github.com/antirez/redlock-rb) gem, integrating it shouldn't be too hard.