Skip to content

sutrolabs/high_school

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High School - a Redis mutex in Ruby and Lua

I had my backpack stolen in high school while I was distracted playing chess. :(

Lesson learned. Keep your stuff safe in your locker.

My loss to high school bullies => your win! :)

Here's a simple Redis based Locker for your stuff.

(Implements the locking strategy from Redis Labs' book about... Redis)

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add high_school

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install high_school

Usage

@locker = HighSchool::Locker.new(my_redis_instance)

@locker.lock(
    "the_name_of_my_lock",
    acquire_timeout: 10.seconds,
    lock_timeout: 1.hour
    ) do

    # keep this code safe from other threads ~~stealing your backpack~~ trampling on.
end

License

The gem is available as open source under the terms of the MIT License.

Feedback

Source code available on Github. Feedback and pull requests are greatly appreciated. Let us know if we can improve this.

From

👋 The folks at Census originally put this together. Have data? We'll sync your data warehouse with your CRM and other apps critical to your team. Interested in what we do? Come work with us.

Releases

No releases published

Packages

No packages published

Languages