Clean redis message cache structure

This commit is contained in:
Ehren Kret
2021-08-11 17:58:51 -05:00
committed by Chris Eager
parent 739c5bf22c
commit ba522b1691
3 changed files with 7 additions and 22 deletions

View File

@@ -9,20 +9,9 @@ for _, guid in ipairs(ARGV) do
if messageId then
local envelope = redis.call("ZRANGEBYSCORE", queueKey, messageId, messageId, "LIMIT", 0, 1)
local sender = redis.call("HGET", queueMetadataKey, messageId)
redis.call("ZREMRANGEBYSCORE", queueKey, messageId, messageId)
redis.call("HDEL", queueMetadataKey, guid)
redis.call("HDEL", queueMetadataKey, messageId .. "guid")
if sender then
redis.call("HDEL", queueMetadataKey, sender)
redis.call("HDEL", queueMetadataKey, messageId)
end
if (redis.call("ZCARD", queueKey) == 0) then
redis.call("ZREM", queueTotalIndexKey, queueKey)
end
if envelope and next(envelope) then
removedMessages[#removedMessages + 1] = envelope[1]
@@ -30,4 +19,10 @@ for _, guid in ipairs(ARGV) do
end
end
if (redis.call("ZCARD", queueKey) == 0) then
redis.call("DEL", queueKey)
redis.call("DEL", queueMetadataKey)
redis.call("ZREM", queueTotalIndexKey, queueKey)
end
return removedMessages