Hacker News new | ask | show | jobs
by ThePhysicist 4413 days ago
I wrote a very similar, Redis-based lock in Python a while ago, here it is:

https://gist.github.com/adewes/6103220

It uses Redis pipelines and watchers to make sure that no race conditions between two processes requiring the same lock occur, and uses "expire" keys to avoid deadlocks.

2 comments

I prefer Lua-scripting based approach: https://github.com/bbangert/retools/blob/master/retools/lock..., but I had to implement something similar to your code to support older Redis versions.