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)
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
@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
The gem is available as open source under the terms of the MIT License.
Source code available on Github. Feedback and pull requests are greatly appreciated. Let us know if we can improve this.
👋 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.