Class: Rjob::Scripts::EnqueueJob
- Inherits:
-
RedisScript
- Object
- RedisScript
- Rjob::Scripts::EnqueueJob
- Defined in:
- lib/rjob/scripts/enqueue_job.rb
Instance Attribute Summary
Attributes inherited from RedisScript
Instance Method Summary collapse
Methods inherited from RedisScript
Instance Method Details
#arg_params ⇒ Object
4 5 6 |
# File 'lib/rjob/scripts/enqueue_job.rb', line 4 def arg_params i(prefix bucket_count job_data) end |
#lua_script ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rjob/scripts/enqueue_job.rb', line 8 def lua_script " local prefix = ARGV[1]\n local bucket_count = tonumber(ARGV[2])\n local job_data = ARGV[3]\n local r = redis\n local job_id = r.call('incr', prefix .. ':next')\n local bucket = job_id % bucket_count\n r.call('lpush', prefix .. ':jobs:' .. bucket, job_id .. '!0!' .. job_data)\n r.call('publish', prefix .. ':jobs', bucket)\n return job_id\n LUA\nend\n" |