mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 00:48:03 +01:00
Remove messages from the cache in bulk.
This commit is contained in:
committed by
Jon Chambers
parent
fc71ced660
commit
c7230ccbb0
@@ -1,28 +1,32 @@
|
||||
-- keys: queue_key, queue_metadata_key, queue_index
|
||||
-- argv: guid_to_remove
|
||||
|
||||
local messageId = redis.call("HGET", KEYS[2], ARGV[1])
|
||||
local removedMessages = {}
|
||||
|
||||
if messageId then
|
||||
local envelope = redis.call("ZRANGEBYSCORE", KEYS[1], messageId, messageId, "LIMIT", 0, 1)
|
||||
local sender = redis.call("HGET", KEYS[2], messageId)
|
||||
for _, guid in ipairs(ARGV) do
|
||||
local messageId = redis.call("HGET", KEYS[2], guid)
|
||||
|
||||
redis.call("ZREMRANGEBYSCORE", KEYS[1], messageId, messageId)
|
||||
redis.call("HDEL", KEYS[2], ARGV[1])
|
||||
redis.call("HDEL", KEYS[2], messageId .. "guid")
|
||||
if messageId then
|
||||
local envelope = redis.call("ZRANGEBYSCORE", KEYS[1], messageId, messageId, "LIMIT", 0, 1)
|
||||
local sender = redis.call("HGET", KEYS[2], messageId)
|
||||
|
||||
if sender then
|
||||
redis.call("HDEL", KEYS[2], sender)
|
||||
redis.call("HDEL", KEYS[2], messageId)
|
||||
end
|
||||
redis.call("ZREMRANGEBYSCORE", KEYS[1], messageId, messageId)
|
||||
redis.call("HDEL", KEYS[2], guid)
|
||||
redis.call("HDEL", KEYS[2], messageId .. "guid")
|
||||
|
||||
if (redis.call("ZCARD", KEYS[1]) == 0) then
|
||||
redis.call("ZREM", KEYS[3], KEYS[1])
|
||||
end
|
||||
if sender then
|
||||
redis.call("HDEL", KEYS[2], sender)
|
||||
redis.call("HDEL", KEYS[2], messageId)
|
||||
end
|
||||
|
||||
if envelope and next(envelope) then
|
||||
return envelope[1]
|
||||
if (redis.call("ZCARD", KEYS[1]) == 0) then
|
||||
redis.call("ZREM", KEYS[3], KEYS[1])
|
||||
end
|
||||
|
||||
if envelope and next(envelope) then
|
||||
removedMessages[#removedMessages + 1] = envelope[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
return removedMessages
|
||||
|
||||
Reference in New Issue
Block a user