Class: Rjob::Scripts::ScanBuckets

Inherits:
RedisScript show all
Defined in:
lib/rjob/scripts/scan_buckets.rb

Instance Attribute Summary

Attributes inherited from RedisScript

#sha1

Instance Method Summary collapse

Methods inherited from RedisScript

#key_params

Instance Method Details

#arg_paramsObject



4
5
6
# File 'lib/rjob/scripts/scan_buckets.rb', line 4

def arg_params
  %i(prefix bucket_count)
end

#lua_scriptObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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