Implementation of a Mutex for Active Record
Latest commit 6d920c1 Dec 7, 2016 @flori Specify correct version
Failed to load latest commit information.
lib Specify correct version Dec 7, 2016
test use command to push reports Nov 23, 2016
.gitignore Disable workaround for wonky mysql behavior now Mar 16, 2016
.travis.yml Start simplecov Nov 23, 2016
Gemfile Add codeclimate token Dec 9, 2014 Bump version Aug 23, 2016
Rakefile Specify correct version Dec 7, 2016
VERSION Specify correct version Dec 7, 2016
active_record_mutex.gemspec Specify correct version Dec 7, 2016



This gem provides a Mutex that is based on ActiveRecord's database connection. (At the moment this only works for Mysql.) It can be used to synchronise ruby processes (also on different hosts) via the connected database.


You can use rubygems to fetch the gem and install it for you:

# gem install active_record_mutex

You can also put this line into your Rails environment.rb file

config.gem 'active_record_mutex'

and install the gem via

$ rake gems:install


If you want to synchronize method calls to your model's methods you can easily do this by passing a mutex instance to ActiveRecord's synchronize class method. This mutex instance will be named Foo like the ActiveRecord was named:

class Foo < ActiveRecord::Base def foo end

synchronize :foo, :with => :mutex


If you want more control over the mutex and/or give it a special name you can create Mutex instance like this:

my_mutex = => 'my_mutex')

Now you can send all messages directly to the Mutex instance.


The homepage of this library is located at


Florian Frank


This software is licensed under the GPL (Version 2) license, see the file COPYING.