Class: Resque::Scheduler::Lock::Basic

Inherits:
Base
  • Object
show all
Defined in:
lib/resque/scheduler/lock/basic.rb

Instance Attribute Summary

Attributes inherited from Base

#key, #timeout

Instance Method Summary collapse

Methods inherited from Base

#initialize, #release, #release!, #value

Constructor Details

This class inherits a constructor from Resque::Scheduler::Lock::Base

Instance Method Details

#acquire!Object



8
9
10
11
12
13
# File 'lib/resque/scheduler/lock/basic.rb', line 8

def acquire!
  if Resque.redis.setnx(key, value)
    extend_lock!
    true
  end
end

#locked?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
# File 'lib/resque/scheduler/lock/basic.rb', line 15

def locked?
  if Resque.redis.get(key) == value
    extend_lock!

    return true if Resque.redis.get(key) == value
  end

  false
end