Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Dec 27, 2024
1 parent 082de4a commit 12bee66
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/FreeRedis/RedisClient/Modules/DelayQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,15 @@ private string InternalDequeue()

//lua脚本保持原子性
var script = @"
local zrange = redis.call('zrangebyscore',KEYS[1],0,ARGV[1],'LIMIT',0,1)
if next(zrange) ~= nil and #zrange > 0
then
local rmnum = redis.call('zrem',KEYS[1],unpack(zrange))
if(rmnum > 0)
then
return zrange
end
else
return {}
end
";
local zrange = redis.call('zrangebyscore',KEYS[1],0,ARGV[1],'LIMIT',0,1)
if next(zrange) ~= nil and #zrange > 0 then
local rmnum = redis.call('zrem',KEYS[1],unpack(zrange))
if(rmnum > 0) then
return zrange
end
else
return {}
end";

if (_redisClient.Eval(script, new[] { _queueKey }, timestamp) is object[] eval && eval.Any())
{
Expand Down

0 comments on commit 12bee66

Please sign in to comment.