When changing the complex type on a record, aerospike:update doesn’t update the data. To make aerospike:update update the complex type the complex type first need to be cloned and then set to the record. Is this the default implementation or is it a bug?
– this doesn’t work
topRec.map[key] = value
aerospike:update(topRec)
– this works
topRec.map = map.clone(topRec.map)
topRec.map[key] = value
aerospike:update(topRec)
I experienced the same problem when writing a generic library to mutate values in a list or map via a UDF (see Aerospike Labs ).
What you have to to is “touch” the bin so that the storage system knows that the bin needs updating in the record
try this code:
function add(topRec, key, value)
if aerospike:exists(topRec) then
if topRec.data == nil then
topRec.data = map()
end
topRec.data[key] = val
-- add this code to "touch the bin"
topRec.data = topRec.data
aerospike:update(topRec)
return topRec.data
end
end
1 Like