Update gestione script LUA:
- cartella con script - conf x scelta - gestione script letti 1 sola volta all'avvio
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
-- RedisUpdateScript_v6
|
||||
local key = KEYS[1]
|
||||
local countInc = tonumber(ARGV[1]) or 0
|
||||
local totalMsInc = tonumber(ARGV[2]) or 0
|
||||
local newMax = tonumber(ARGV[3])
|
||||
local newMin = tonumber(ARGV[4])
|
||||
local sentinel = tonumber(ARGV[5])
|
||||
|
||||
-- Incrementi
|
||||
redis.call('HINCRBY', key, 'count', countInc)
|
||||
redis.call('HINCRBYFLOAT', key, 'totalMs', totalMsInc)
|
||||
|
||||
-- MAX
|
||||
local currentMaxStr = redis.call('HGET', key, 'maxMs')
|
||||
local currentMax = tonumber(currentMaxStr)
|
||||
|
||||
if newMax ~= nil and newMax < sentinel then
|
||||
if currentMax == nil or newMax > currentMax then
|
||||
redis.call('HSET', key, 'maxMs', tostring(newMax))
|
||||
end
|
||||
end
|
||||
|
||||
-- MIN
|
||||
local currentMinStr = redis.call('HGET', key, 'minMs')
|
||||
local currentMin = tonumber(currentMinStr)
|
||||
|
||||
if newMin ~= nil and newMin < sentinel then
|
||||
if currentMin == nil or newMin < currentMin then
|
||||
redis.call('HSET', key, 'minMs', tostring(newMin))
|
||||
end
|
||||
end
|
||||
|
||||
return 1
|
||||
Reference in New Issue
Block a user