Skip to content

Instantly share code, notes, and snippets.

View stefanvermaas's full-sized avatar
👨‍💻

Stefan Vermaas stefanvermaas

👨‍💻
View GitHub Profile
@stefanvermaas
stefanvermaas / temporary_lock.rb
Last active August 4, 2022 17:36 — forked from ikzekly/temporary_lock.rb
Provides Redis distributed lock api
# frozen_string_literal: true
# @example provides Redis distributed lock api
#
# $ TemporaryLock.create!(:example, 'c22a0420-51c8-4e47-843c-92a37e8d2eba')
# => #<TemporaryLock:0x000055b43e328410 @key="temporary_lock:example:c22a0420-51c8-4e47-843c-92a37e8d2eba">
#
# @example raises `TemporaryLock::StaleObjectError` when `id` already registered
#
# $ TemporaryLock.create!(:example, 'c22a0420-51c8-4e47-843c-92a37e8d2eba')
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.progress {
position: absolute;
top: 0;
left: 0;