Class: UniqueJob::JobHistory
- Inherits:
-
Object
- Object
- UniqueJob::JobHistory
- Includes:
- Logging
- Defined in:
- lib/unique_job/job_history.rb
Instance Method Summary collapse
- #add(v1, v2, ttl) ⇒ Object
- #exists?(v1, v2) ⇒ Boolean
-
#initialize(middleware_name, redis) ⇒ JobHistory
constructor
A new instance of JobHistory.
Methods included from Logging
Constructor Details
#initialize(middleware_name, redis) ⇒ JobHistory
Returns a new instance of JobHistory.
7 8 9 10 |
# File 'lib/unique_job/job_history.rb', line 7 def initialize(middleware_name, redis) @key_prefix = "#{self.class}:#{middleware_name.split('::')[-1]}" @redis = redis end |
Instance Method Details
#add(v1, v2, ttl) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/unique_job/job_history.rb', line 19 def add(v1, v2, ttl) @redis.setex(key(v1, v2), ttl, true) rescue => e logger.warn { "[UniqueJob] Redis#setex failed v1=#{v1} v2=#{v2} ttl=#{ttl} exception=#{e.inspect}" } nil end |
#exists?(v1, v2) ⇒ Boolean
12 13 14 15 16 17 |
# File 'lib/unique_job/job_history.rb', line 12 def exists?(v1, v2) @redis.exists?(key(v1, v2)) rescue => e logger.warn { "[UniqueJob] Redis#exists? failed v1=#{v1} v2=#{v2} exception=#{e.inspect}" } nil end |