Class: Rjob::Scripts::ScheduleJobAt
- Inherits:
-
RedisScript
- Object
- RedisScript
- Rjob::Scripts::ScheduleJobAt
- Defined in:
- lib/rjob/scripts/schedule_job_at.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/schedule_job_at.rb', line 4 def arg_params %i(timestamp job prefix bucket_count) end |
#lua_script ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rjob/scripts/schedule_job_at.rb', line 8 def lua_script <<~LUA local timestamp = ARGV[1] local job = ARGV[2] local prefix = ARGV[3] local bucket_count = tonumber(ARGV[4]) local r = redis local job_id = r.call('incr', prefix .. ':next') local bucket = job_id % bucket_count r.call('zadd', prefix .. ':scheduled:' .. bucket, timestamp, job_id .. '!0!' .. job) return job_id LUA end |