Best way to save inventories?

Discussion in 'Plugin Development' started by Mike724, Sep 25, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Mike724

    What is the best way, and quickest (as in least strain on the server) way to save inventories via a Bukkit plugin? I'm not sure if YAML, SQL, flatfile, ect, is best.:oops:
     
  2. Offline

    Kodfod

    I save them into HashMaps that get written into files....

    Haven't had any problems That way.
     
    Mike724 likes this.
  3. Offline

    Mike724

    Like in the one plugin tutorial that saves them to a .bin?
     
  4. Offline

    Neodork

  5. Offline

    Netizen

    This is a good question.

    From a performance standpoint, it is fastest to save things into a flatfile, or YAML file provided you code it correctly. SQL is slower at saving things, but can be much faster at looking things up, especially if you need to look up complex relationships. So it depends on what exactly you want to do.

    I would go with saving inventories to a flatfile. Making some assumptions about what you're using it for, I suspect you'll have a lot more "save" operations than "load" operations and you will want to make sure that every update to a player's inventory is properly saved.
     
    Mike724 likes this.
  6. Offline

    Mike724

    That actually looks great, I might just use that and YAML.

    Yeah I will be saving the inventory quite a bit, and loading it a lot less. I'm going to use the inventory to string and YAML most likely, unless someone else has a better idea.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  7. Offline

    Neodork

    Just make sure you only save the Yaml when necessary. And you might want to consider replacing all the "save" lines for a single repeating task IF your going to save to your Yaml a lot.
     
  8. Offline

    Mike724

    I'm going to only save when needed and save for all players every 15-30 minutes just in case, I don't want any inventories lost. ;)
     
  9. Offline

    Neodork

    Good luck to you, thanks for the like.
     
Thread Status:
Not open for further replies.

Share This Page