i use config.yml as storage for stuff, but i load the config's data to an array when the server enables. which gives me some freezes when server enables. is there any way to do something like this? like add the players data in config to array when they join . i also save the data to config when server disables.
Hello, I think that the best way to optimize your config file and therefore no longer have freeze would be to create a folder for each new player on the server. Then you can easily enter and edit information because you only have to recover the file in question Be careful, however, not to use too much character because the memory deals quickly ... with this method, the server will only have to check the requested file and not a long file containing the information of all the players
When you save everything in a single yaml file, you're making it progressively slower to seriliaze/unserialize everytime you read from or write to it. My recommendation is to use some SQL database such as MySQL, SQLite, etc. Or if don't care about performance and really want to use yaml, it would in fact be better to store everything into fragments that way on startup you won't have to load a big file. Say a player joins, you'll only have to search for the file of that specific player and it'll take relatively shorter to unserialize.
Yeah, this is exactly why you must not use a config as a database. What you could do is: Save player data into their own files, but read the file asynchronously — that way you don't need to read everything to get one thing. Crumble everything into one file but dedicate each line in the file for 1 player, store the line number somewhere as an index (but where would you store the line number?) — I don't know about this. Use a database that is optimized for such things (such as MySQL or MongoDB) to store player data.