Best Method to Search Values on Files

Discussion and help for Easy Save 3
Post Reply
basonliew
Posts: 2
Joined: Mon Jul 13, 2020 3:46 am

Best Method to Search Values on Files

Post by basonliew »

Hi! This is my first time posting so please pardon me if I missed anything! Recently bought this great assets!

I am trying to create a multiplayer game, to simplify things, I have mySQL storing all the files that were created by individual players. eg:
-5 players files are saved as a blob in mySQL (5 PlayerData.ES3)
-Each file contains let's say Username, and first name in each Json
-Is there a way where I can loop through all the above 5 files to check the username for duplication somehow like how SQL works? Don't have to be like SQL but any method to loop and does not affect performance issue :)

Hope to hear from you soon!
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Best Method to Search Values on Files

Post by Joel »

Hi there, and thanks for getting in contact.

The most efficient way to access keys in a file is to load them into the cache. I.e. something like this:

Code: Select all

var settings = new ES3Settings(ES3.Location.Cache);
foreach(var file in ES3.GetFiles())
{
	ES3.CacheFile(file);
	var username = ES3.Load<string>("username", settings);
	var firstName = ES3.Load<string>("firstName", settings);
}
For more information on caching please see this guide:
https://docs.moodkie.com/easy-save-3/es ... rformance/

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
basonliew
Posts: 2
Joined: Mon Jul 13, 2020 3:46 am

Re: Best Method to Search Values on Files

Post by basonliew »

Hi Joel,

Thank you for your fast response! Does that mean that if I have 1000 players, I have to load all the files to cache? Sorry as I tried to read the documentation and are not able to catch it due to my own fault :( I actually wanted to do a highscore by getting all the same keys and compare the scores.

Thanks again Joel, this asset is really amazing!
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Best Method to Search Values on Files

Post by Joel »

Hi there,

That is correct, as it's not possible to know what's inside a file without opening it. I would recommend using ES3.Load to load from each of them first, and if you're finding this causes issues with performance then try using caching.

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