Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.
/ monogamy Public archive
forked from mceachen/monogamy

Add table-level database locking to ActiveRecord

License

Notifications You must be signed in to change notification settings

soomo/monogamy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monogamy

Adds table-level locking to ActiveRecord 3.2 and 4.0. MySQL and PostgreSQL are supported.

Build Status Gem Version Dependency Status

Usage

Tag.with_table_lock do
  Tag.where(name: "example").first_or_create
end

While your code is inside the block, it will have exclusive read and write access to the model's table.

A transaction will be opened and closed for you automatically during your block's execution. There's no need to wrap your call to with_table_lock with a transaction do.

If your block touches other tables, and you use table-level locking on those tables as well, read up about deadlocks. You have been warned.

Installation

Add this line to your application's Gemfile:

gem 'monogamy'

And then execute:

$ bundle

Changelog

0.0.1

  • First whack

About

Add table-level database locking to ActiveRecord

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 97.2%
  • Logos 2.8%