How can I save individual data without having to save the entire array after each chat message?

Discussion and help for Easy Save 3
Post Reply
tuanha
Posts: 12
Joined: Wed Jun 08, 2022 1:41 am

How can I save individual data without having to save the entire array after each chat message?

Post by tuanha »

I have a chat array like this: public List<InfoChat> lstCHATLISTs = new List<InfoChat>();. Every time I send a chat message, I want to save the data using Easy Save. Currently, when saving, I have to load the entire lstCHATLISTs array and then save the whole array again. If there's a large amount of data, this approach is not optimal. Do you have a way to save individual chat messages using Easy Save without having to save the entire lstCHATLISTs array?

I hope for the assistance of the Admin and everyone.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: How can I save individual data without having to save the entire array after each chat message?

Post by Joel »

Hi there,
Currently, when saving, I have to load the entire lstCHATLISTs array and then save the whole array again.
Usually you would keep the array in a variable so that you don't need to load it every time you save. That way you only need to load it once before saving for the first time, and then that array will always be consistent with the array in the file.

The only alternative if you do want to save directly to file is to save each item to a separate key. However, this will be less performant and less maintainable than simply putting your array in a variable as described above, and you will definitely want to use caching as described here:

https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply