Skip to content

Commit

Permalink
Merged @unclebilly's ttl feature with some mini changes and a 1.2.0 v…
Browse files Browse the repository at this point in the history
…ersion bump
  • Loading branch information
jayniz committed Jan 5, 2012
1 parent d48cfd8 commit 50371b0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
1.2.0
--------------------------------
Thanks @unclebilly for your pull request. Resque-loner now supports
a maximum time for which a job should be unique. Just define @loner_ttl
in your job (or leave it at -1 to never expire) and after @loner_ttl
seconds your job can be enqueued again, even if an older one is still
marked as running.

1.1.0
--------------------------------
Merged in @ryansch's pull requests to clean up things a bit.
Expand Down
11 changes: 5 additions & 6 deletions lib/resque-loner/unique_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ def redis_key(payload)
end

#
# The default ttl of a locking key is -1, i.e. forever. If for some reason you only
# want the lock to be in place after a certain amount of time, override this method
# in your job. For example:
# The default ttl of a locking key is -1, i.e. forever. If for some reason you only
# want the lock to be in place after a certain amount of time, just set a ttl for
# for your job. For example:
#
# class FooJob
# include Resque::Plugins::UniqueJob
# def self.loner_ttl
# 40
# @loner_ttl = 40
# end
# end
#
def loner_ttl
-1
@loner_ttl || -1
end

end # ClassMethods
Expand Down
2 changes: 1 addition & 1 deletion lib/resque-loner/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Resque
module Plugins
module Loner
VERSION = "1.1.0"
VERSION = "1.2.0"
end
end
end
5 changes: 1 addition & 4 deletions spec/loner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def self.perform(foo); end
class UniqueJobWithTtl
include Resque::Plugins::UniqueJob
@queue = :unique_with_ttl

def self.loner_ttl
300
end
@loner_ttl = 300

def self.perform(*args); end
end
Expand Down

0 comments on commit 50371b0

Please sign in to comment.