Class: Istox::DLMBoot

Inherits:
Object
  • Object
show all
Defined in:
lib/istox/helpers/dlm.rb

Class Method Summary collapse

Class Method Details

.lock(key, timeout = 3600, db) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/istox/helpers/dlm.rb', line 4

def lock(key, timeout = 3600, db)
  loop do
    break if ::Istox::RedisBoot.sets(key, 1, {nx: true, px: timeout}, db)
  end

  begin
    yield
  ensure
    ::Istox::RedisBoot.del key, db
  end
end