1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

optimizing yaml storage

Discussion in 'General discussion' started by Levi, Jul 17, 2018.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    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.
     
    Last edited: Jul 17, 2018
  2. MisterTurtle

    MisterTurtle Creeper

    Messages:
    5
    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
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Isn't making folder for each player even badder
     
  4. Eduardo

    Eduardo Baby Zombie

    Messages:
    100
    GitHub:
    xBeastMode
    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.
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    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.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.