I was having a break right now so i read some topics on devforum. There is one topic related to Datastore and they use UpdateAsync so i was wondering why would a lot of people recommend to use UpdateAsync over SetAsync?
UpdateAsync takes into consideration of the previous value before making the change, and SetAsync doesn’t, which is why developers prefer to use UpdateAsync. You can learn more about this here:
what does it mean by considering old values? From what i understand, it sounds like there is an if statement to check whether the value was changed or not. If that is the case, i could just use an if statement combine with setasync
Then you have 2 async calls to get the data then set the data. As opposed to one async call. Unless your data is cached as well, which may not be the case if devs don’t need quick access to it at all times. But honestly this explains why better:
so is it gonna be laggy if the game constantly trying to save data or any problem associated with?
It’s not that it’ll be laggy, but it’ll take more time overall and you’ll drop a lot more requests using GetAsync
SetAsync
than to UpdateAsync
. Also, if you’re constantly get/setting the same key you’ll run into problems with DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = Key
.
thanks a lot for your advice and your explaination