Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: removed deprecated commands 'zrangebyscore' and 'rpoplpush' #5

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Go template
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories
vendor/

# Go land
.idea/

12 changes: 6 additions & 6 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ for i=1,keylen,%d do

if haveJobs(jobQueue) and not isPaused(pauseKey) and canRun(lockKey, maxConcurrency) then
acquireLock(lockKey, lockInfoKey, workerPoolID)
res = redis.call('rpoplpush', jobQueue, inProgQueue)
res = redis.call('LMOVE', jobQueue, inProgQueue, 'RIGHT', 'LEFT')
return {res, jobQueue, inProgQueue}
end
end
Expand Down Expand Up @@ -178,7 +178,7 @@ for i=1,keylen,%d do
jobQueue = KEYS[i+1]
lockKey = KEYS[i+2]
lockInfoKey = KEYS[i+3]
res = redis.call('rpoplpush', inProgQueue, jobQueue)
res = redis.call('LMOVE', inProgQueue, jobQueue, 'RIGHT', 'LEFT')
if res then
releaseLock(lockKey, lockInfoKey, workerPoolID)
return {res, inProgQueue, jobQueue}
Expand Down Expand Up @@ -225,7 +225,7 @@ return nil
// ARGV[2] = current time in epoch seconds
var redisLuaZremLpushCmd = `
local res, j, queue
res = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[2], 'LIMIT', 0, 1)
res = redis.call('ZRANGE', KEYS[1], '-inf', ARGV[2], 'BYSCORE', 'LIMIT', 0, 1)
if #res > 0 then
j = cjson.decode(res[1])
redis.call('zrem', KEYS[1], res[1])
Expand All @@ -245,7 +245,7 @@ return nil
// - job bytes (last job only)
var redisLuaDeleteSingleCmd = `
local jobs, i, j, deletedCount, jobBytes
jobs = redis.call('zrangebyscore', KEYS[1], ARGV[1], ARGV[1])
jobs = redis.call('ZRANGE', KEYS[1], ARGV[1], ARGV[1], 'BYSCORE')
local jobCount = #jobs
jobBytes = ''
deletedCount = 0
Expand All @@ -269,7 +269,7 @@ return {deletedCount, jobBytes}
// Returns: number of jobs requeued (typically 1 or 0)
var redisLuaRequeueSingleDeadCmd = `
local jobs, i, j, queue, requeuedCount
jobs = redis.call('zrangebyscore', KEYS[1], ARGV[3], ARGV[3])
jobs = redis.call('ZRANGE', KEYS[1], ARGV[3], ARGV[3], 'BYSCORE')
local jobCount = #jobs
requeuedCount = 0
for i=1,jobCount do
Expand All @@ -296,7 +296,7 @@ return requeuedCount
// Returns: number of jobs requeued
var redisLuaRequeueAllDeadCmd = `
local jobs, i, j, queue, requeuedCount
jobs = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[2], 'LIMIT', 0, ARGV[3])
jobs = redis.call('ZRANGE', KEYS[1], '-inf', ARGV[2], 'BYSCORE', 'LIMIT', 0, ARGV[3])
local jobCount = #jobs
requeuedCount = 0
for i=1,jobCount do
Expand Down