PeopleAdmin/qtrix — pull request #13 by lwoodson (2013-09-23 04:43:36+00:00)
Title: Proper locking

This pull request implements a locking mechanism and protects certain should-be-atomic operations with locks. This provides the ```Qtrix::Locking``` module that provides a ```with_lock``` method like so:

```ruby
with_lock(a_value_if_deadlocked) do
# ... some code
end
```

This code will attempt to acquire the lock for a short time and if its obtained, execute and return the value of the block. If the lock cannot be obtained, the parameter passed to the with_lock method will be returned (or an exception raised if none provided).

This uses [mlanett-redis-lock](https://github.com/mlanett/redis-lock) under the covers. This had several appealing aspects to it:

* Accomplishes what we want.
* Seemed to be the most active of the ruby redis locking gems (at least according to ruby-toolbox).
* Code/approach within the gem looked solid
* Its lightweight and does not introduce any additional dependencies.

A few things to gate this:

- [ ] Test and evaluate the lock's acquire and duration values (0.3 and 5 seconds).
- [ ] Test under stress with stressque.