Method: Kthxbye#salvage
- Defined in:
- lib/kthxbye.rb
#salvage(q) ⇒ Object
This method is used mostly internally to pop the next job off of the given queue. It takes in a string representing a queue and will return a Kthxbye::Job object if a job exists on the queue. This is destructive on the queue as it will REMOVE the next job off queue and return the job object.
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/kthxbye.rb', line 106 def salvage(q) id = redis.lpop( "queue:#{q}" ) if id payload = decode( redis.hget( "data-store:#{q}", id ) ) return Job.new(id, q, payload) else log "No jobs found in #{q}" return nil end end |