Class: Resque::JobFetch
- Inherits:
-
Object
- Object
- Resque::JobFetch
- Defined in:
- lib/resque-priority-jobs.rb
Class Method Summary collapse
Class Method Details
.fetch_one_job(redis, queue) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/resque-priority-jobs.rb', line 36 def self.fetch_one_job(redis, queue) #lua script to get item with maximum priority get_and_rem = "local resp = redis.call('zrangebyscore', KEYS[1], '-inf', '+inf', 'LIMIT', '0', '1'); if (resp[1] ~= nil) then local val = resp[# resp] redis.call('zrem', KEYS[1], val) return val else return false end" redis.eval get_and_rem, [queue] end |