redis-locker

A super-FAST and super-ROBUST LOCKING mechanism. Builds queue of concurrent code blocks using Redis.

If Redis fails at some point (cleared, filled with wrong data, stuck) it will be trying to stay alive anyway. This is supported by additional key-control.

Installing

$ gem install redis-locker

Or put in your gemfile for latest version:

gem 'redis-locker', git: 'git://github.com/einzige/redis-locker.git'

Using

# Throws an error if transaction will not be finished in 10 seconds
RedisLocker.new('payment_transaction').run!(10.seconds) do
  # Any concurrent code.
end

# Throws an error if transaction will not be finished in 10 seconds
# Clears all stale tasks which were not performed within 10 seconds
RedisLocker.new('payment_transaction', 10.seconds).run! do
  # Any concurrent code.
end

# Does not throw any error, but clears all stale tasks which were not performed within 10 seconds
RedisLocker.new('payment_transaction', 10.seconds).run do
  # Any concurrent code.
end

Running specs

Contributing to redis-locker

Copyright © 2013 Sergei Zinin. No LICENSE for details :)