class Rjob::Scripts::ScanBuckets

Public Instance Methods

arg_params() click to toggle source
# File lib/rjob/scripts/scan_buckets.rb, line 4
def arg_params
  %i(prefix bucket_count)
end
lua_script() click to toggle source
# File lib/rjob/scripts/scan_buckets.rb, line 8
  def lua_script
    <<~LUA
      local prefix = ARGV[1]
      local bucket_count = ARGV[2]
      local r = redis
      local i
      for i=0,bucket_count-1 do
        local len = r.call('llen', prefix .. ':jobs:' .. i)
        if len > 0 then
          r.call('publish', prefix .. ':jobs', tostring(i))
        end
      end
      return 1
    LUA
  end