UpdateAsync or SetAsync

UpdateAsync is used so that keys can be modified relatively in arbitrary order instead of being set based on what the server stored. Since servers might try to assign data to the same key at the same time (for whatever youre trying to do) it will apply the updates based on which one gets there first. This way instead of permanently setting the value to oldsave+5, it would be set to oldsave+5+5+5… because of the function

function(oldsave) return oldsave+5 end

I typically use SetAsync because i have not found a reason to use UpdateAsync yet. I think an example might be people can plant crops that stay until the server dies (bad example but). They would earn cash from the crops in different servers. This would not work very well if the cash they had was stored on the server and SetAsync was used because servers may have older data values and create conflicting saves.

5 Likes