Sha256: b50b0896e5ff807ab670e1d03d1683ed16b34d2dd2a0d496f915ae7e7a779184

Contents?: true

Size: 345 Bytes

Versions: 3

Compression:

Stored size: 345 Bytes

Contents

class RedisLock
  class Semaphore < Strategy

    def call(&block)
      ttl = args[:ttl] || lock.config.default_ttl
      set_opts = args[:set_opts] || {}
      while lock.locked?
        sleep (args[:wait] || 1)
      end
      lock.set(ttl, set_opts)
      _perform(&block)
    end

    def after_perform
      lock.unlock!
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redis_lock-0.4.4 lib/redis_lock/semaphore.rb
redis_lock-0.4.3 lib/redis_lock/semaphore.rb
redis_lock-0.4.2 lib/redis_lock/semaphore.rb