Im trying to figure out the best way to save/store my games data.
I have around 100 bits of data I need to save.
Currently every 10 seconds, I save the game. Any changes made, are added to a string/string dictionary and only those ones are pushed to the cloud. So only the specific data that changes is being saved every x seconds.
Currently, im merging similair datas together (so it reduces the number of keys, but means that data that isnt changed gets saved due to the concatenation).
EG: There are 5 characters, each with 3 stats, so im storing those as a string that I pull apart in the client, and when I go to save, I put it into this string before sending back to the cloud
"1;2;3;1;3;2;1;3;2;1;3;0;0;0;0"
so thats 1 key in the database which I essentially turn into 15 in the client.
But if only player 1's power is updated, all 14 other stats are saved as well (29 chars are saved unnecessarily), so im just trying to optimise this a little better.
It is my understanding that less keys is better.
So having everything seperate EG:
Player1Power: 1
Player1Speed: 2
Player1Level: 3
Player2Power: 3
etc
is terrible compared to having it all as one EG:
PlayerStats: 1;2;3;1;3;2;1;etc
This also makes it a little hard to read though visually if I wanted to log into playfab and play around with it. So another thing im trying to figure out is, is the storing of the data the problem or the transfering?
If its simply the transferring, then would I be just as well off storing the data seperatly (Player1Power, Player1Speed, etc) and simply have a RetrieveStats Cloud Script function that takes those 15 keys, makes 1 key out of them and sends that to the client?
Likewise another one for saving the stats - getting sent 1 key, pulling it apart and saving the 15 keys seperatly.
If that is a good option, my goal would be to have 1 Save function that can pull apart any string, figure out how many keys it needs to become and save a dynamic number of keys from it.
If its the number of keys in the database as the problem, would I be good to do what im doing (save larger strings even if only a small bit of them is the relevant changed data) or would I be even better off - sending a cloud function something like "3;2" - the function would then change the 3rd character in the saved string to "2".
- or, call a function that would act as a 'UpgradePlayer1Power' which would change the 3rd char in the saved string to a +1.
(is sending 'no' data best/fastest when sending to the cloud? So having a separate cloud function for every thing I want to save and calling each one properly, or having a function I can send some indicators to to tell it 'give me player 1's power')