"Fossies" - the Fresh Open Source Software Archive

Member "Signal-Server-11.17.0/service/src/main/resources/lua/remove_item_by_guid.lua" (30 Nov 2023, 808 Bytes) of package /linux/www/Signal-Server-11.17.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 local queueKey           = KEYS[1]
    2 local queueMetadataKey   = KEYS[2]
    3 local queueTotalIndexKey = KEYS[3]
    4 
    5 local removedMessages = {}
    6 
    7 for _, guid in ipairs(ARGV) do
    8     local messageId = redis.call("HGET", queueMetadataKey, guid)
    9 
   10     if messageId then
   11         local envelope = redis.call("ZRANGEBYSCORE", queueKey, messageId, messageId, "LIMIT", 0, 1)
   12 
   13         redis.call("ZREMRANGEBYSCORE", queueKey, messageId, messageId)
   14         redis.call("HDEL", queueMetadataKey, guid)
   15 
   16         if envelope and next(envelope) then
   17             removedMessages[#removedMessages + 1] = envelope[1]
   18         end
   19     end
   20 end
   21 
   22 if (redis.call("ZCARD", queueKey) == 0) then
   23     redis.call("DEL", queueKey)
   24     redis.call("DEL", queueMetadataKey)
   25     redis.call("ZREM", queueTotalIndexKey, queueKey)
   26 end
   27 
   28 return removedMessages