module Tor::Lock
Public Instance Methods
lock(key, expires: 10.minutes, timeout: 1.hour) { || ... }
click to toggle source
# File lib/rest_tor/lock.rb, line 3 def lock(key, expires: 10.minutes, timeout: 1.hour, &block) Redis::Lock.new("tor:lock:#{key}", expiration: expires, timeout: timeout).lock { yield } end
locked?(key)
click to toggle source
# File lib/rest_tor/lock.rb, line 7 def locked?(key) Redis.current.get("tor:lock:#{key}") end
unlock!(key)
click to toggle source
# File lib/rest_tor/lock.rb, line 11 def unlock!(key) Redis.current.del("tor:lock:#{key}") end