lib/redis_locks/semaphore.rb
def unlock(token = @tokens.pop)
      return unless token

      removed = false

      @redis.with do |conn|
        removed = conn.zrem grabbed_key, token
        if removed
          conn.lpush available_key, 1
        end
      end

      removed
    end
def unlock(token = @tokens.pop)
      return unless token

      removed = false

      @redis.with do |conn|
        removed = conn.zrem grabbed_key, token
        if removed
          conn.lpush available_key, 1
        end
      end

      removed
    end
Release a resource back to the semaphore. Should normally be called with an
 explicit token.

 This isn't atomic--if the process dies, we could remove something from the
 blocked set without adding it to the available queue--but that's ok, the
 semaphore will recover just as if this was a stale client that left its
 token in the grabbed set forever.