Would looping through 5000-10000 file checking for 1 section in each file, be server extensive? will players feel a 2 second freeze/rubberband?
@Protophite Depends on your system. How good is your CPU. I'm assuming this is for player data. If you only have a small amount of data for each player (under 100 lines in the file), merge the files.
@mythbusterma I store data for player in a YAML file. When a player joins I store everything in a custom player object. When the player leaves/quits, the object is stored in a list. Every so often the variable is cleared and everything saves to their file. Please tell me the most effective way besides MySQL. That's basically what I'm doing. I needed to iterate through all files if I wasnt able to get a players UUID. It was solved by using this: Code: OfflinePlayer op = Bukkit.getOfflinePlayer(playername); //deprecated if(op.hasPlayedBefore()) //get UUID //retrieve the file //blabla
I would recommend using some sort of cache, but you should use the default yml config, but why not save to 1 file? Also i fell over this the other day, i havent used it but thought you may find it useful. https://bukkit.org/threads/thunderbolt-2-lightning-fast-data-storage.335293/
@Protophite Yes, but do not try to access any bukkit api inside the async thread without compenstating for what you are doing. Thread safety was somewhat explained here. https://bukkit.org/threads/why-is-thread-safety-important.441942/ You could do it with a bukkitrunnable. BukkitRunnable#runTaskTimerAsynchronously(Plugin plugin)
@Protophite Well it doesn't have to be MySQL, you could do SQLite or PostgreSQL. But the best option is definitely using an SQL database, indexing the field, and then searching on it.