Permalink
Browse files

Merge pull request #20 from aerodynamik/patch-1

atomic unique job creation
  • Loading branch information...
2 parents 50371b0 + 4ae90ae commit 9ec74bbb17e7a92c571cb6b5250c0101bb7ad01a @jayniz jayniz committed Apr 27, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/resque-ext/job.rb
@@ -15,9 +15,11 @@ def self.create_with_loner(queue, klass, *args)
return create_without_loner(queue, klass, *args) if Resque.inline?
item = { :class => klass.to_s, :args => args }
return "EXISTED" if Resque::Plugins::Loner::Helpers.loner_queued?(queue, item)
- job = create_without_loner(queue, klass, *args)
- Resque::Plugins::Loner::Helpers.mark_loner_as_queued(queue, item)
- job
+ # multi block returns array of keys
+ Resque.redis.multi do
+ create_without_loner(queue, klass, *args)
+ Resque::Plugins::Loner::Helpers.mark_loner_as_queued(queue, item)
+ end.first
end
#

0 comments on commit 9ec74bb

Please sign in to comment.