mloughran / em-hiredis

Eventmachine redis client
MIT License
221 stars 63 forks source link

Better locking #25

Closed mdpye closed 10 years ago

mdpye commented 10 years ago

Re-implemented Lock using lua scripting to provide a considerably simpler and safer mechanism for locking.

Also add some tests to the locking implementation.

Let's get lua_support merged and released as well!

mdpye commented 10 years ago

We already require this for all the lua scripts in pusher-server. I wrote a setex version, but it's phenomenally complicated in comparison and I still knew of at least one failure case.

They even note that the setex pattern is crop in it's own documentation...

mdpye commented 10 years ago

I was confusing SETEX and SETNX. SETEX is the same technique with better backwards compatibility, SETNX is the old algorithm.

pl commented 10 years ago

Looks good, but I think it would be useful to have specs for the persistent lock.

mdpye commented 10 years ago

Agreed, I'm not dead clear on the best way to write them though. I'd like to write a true unit test by mocking both the lock and the timers. I'll have a go.

masha256 commented 10 years ago

Any chance the improved locking version will be released as an updated gem soon? I have a separate project where I implemented the LUA-based locking and its great, and rather than perpetuate that code, I would much rather use the better locking you guys have developed here. Persistence locking is exactly what my new project needs!

mloughran commented 10 years ago

@machadolab yes, looks like a release is due - I'll try to get one out soon.

mloughran commented 10 years ago

@machadolab I just released 0.3.0