2
Aerospike記錄UDF是原子的嗎?Aerospike記錄UDF是原子性的嗎?
function increment_and_expire(rec, incValue, expireThreshold, currentTime)
if aerospike:exists(rec) then
local timesUsed = rec['timesUsed']
if timesUsed == expireThreshold or rec['validUpto'] < currentTime then
rec['expired'] = true
else
rec['timesUsed'] = timesUsed + incValue
end
aerospike:update(rec)
return 1
else
warn("record doesn't exists")
return -1
end
end
上面的Lua函數增加了令牌的使用,如果它不再有效,它會將其標記爲過期。 現在我的疑問是,如果併發請求來自同一條記錄,並且此函數正在同時執行,是否會導致任何問題?