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

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’re doing? Come work with us.

Nate Kontny

Nate is a hands-on developer building products and running companies. His previous experience as the CEO of Highrise and CTO of Inkling helped him hone his skills as a software designer, engineer, founder, writer & vlogger. You should follow him on YouTube: here.

http://youtube.com/nathankontny
Previous
Previous

Insignificant

Next
Next

External Garbage Collection