@redis.pipelined
で突っ込んでいた
def enqueue(klass, *args)
enqueue_to(queue_from_class(klass), klass, *args)
end
def enqueue_to(queue, klass, *args)
# Perform before_enqueue hooks. Don't perform enqueue if any hook returns false
before_hooks = Plugin.before_enqueue_hooks(klass).collect do |hook|
klass.send(hook, *args)
end
return nil if before_hooks.any? { |result| result == false }
Job.create(queue, klass, *args)
Plugin.after_enqueue_hooks(klass).each do |hook|
klass.send(hook, *args)
end
return true
end
def self.create(queue, klass, *args)
Resque.validate(klass, queue)
if Resque.inline?
# Instantiating a Resque::Job and calling perform on it so callbacks run
# decode(encode(args)) to ensure that args are normalized in the same manner as a non-inline job
new(:inline, {'class' => klass, 'args' => decode(encode(args))}).perform
else
Resque.push(queue, :class => klass.to_s, :args => args)
end
end
def push(queue, item)
data_store.push_to_queue(queue,encode(item))
end
/lib/resque/data_store.rb#L102-L107
def push_to_queue(queue,encoded_item)
@redis.pipelined do
watch_queue(queue)
@redis.rpush redis_key_for_queue(queue), encoded_item
end
end