Permalink
Browse files

atomic unique job creation

  • Loading branch information...
1 parent 50371b0 commit 4ae90aec46471b7b7481059dda82db771a961c75 @aerodynamik aerodynamik committed Apr 27, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/resque-ext/job.rb
View
8 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 4ae90ae

Please sign in to comment.