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函数增加了 token 的使用,如果它不再有效,则将其标记为过期。 现在我的疑问是,如果并发请求来自同一条记录并且该函数同时执行,会导致任何问题吗?
最佳答案
您问的是隔离性,而不是真正的原子性。 Aerospike 按每个键以序列化方式执行所有事务。即,一对一写入事务可以在任何给定时间点在 key 上处于事件状态。其他人都得等待。执行顺序不一定是 FIFO,而是串行化的。 udf 也是如此。
关于lua - Aerospike Record UDF 是原子的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36517405/