Gather IP-based metrics for international, unsealed-sender messages.

This commit is contained in:
Jon Chambers
2021-03-04 11:47:13 -05:00
committed by Jon Chambers
parent df9dc82de5
commit f57a4171ba
4 changed files with 143 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
local destinationSetKey = KEYS[1]
local messageCountKey = KEYS[2]
local destination = ARGV[1]
redis.call("PFADD", destinationSetKey, destination)
local distinctDestinationCount = redis.call("PFCOUNT", destinationSetKey)
if redis.call("TTL", destinationSetKey) < 0 then
redis.call("EXPIRE", destinationSetKey, 86400)
end
local messageCount = redis.call("INCR", messageCountKey)
if messageCount == 1 then
redis.call("EXPIRE", messageCountKey, 86400)
end
return { distinctDestinationCount, messageCount }