Solved Database or alternate datastorage?

Discussion in 'Plugin Development' started by GiantDwarf01, Sep 27, 2015.

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

    GiantDwarf01

    Hello, I am making a plugin that requires loading and saving lots of data constantly in a database type format. Currently I'm using MySQL but I'm not sure about having to have a separate server host for it is the best solution. So are there any other solutions I can use? Hashmap won't work I think because I'm storing multiple data in a single row, and a multidimensional array might work, but it doesn't seem particularly convenient or applicable in this situation. Thanks for any help.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @GiantDwarf01 MySQL takes time to read and write.
    Why not a hashmap that contains a list of items?
    Or create a custom class designed to store whatever you need to store.
     
    Konato_K likes this.
  3. Offline

    Tecno_Wizard

    @timtower, isn't there a regional DB system built into Bukkit? I've seen it used before.
     
  4. Offline

    timtower Administrator Administrator Moderator

    There is, don't fully know how to use it though.
    But it is still a database so the question is how fast it is.
     
  5. I'd say use a Map and then load/save to the database on enable/disable
     
  6. Offline

    Tecno_Wizard

    @bwfcwalshy, depending on what that data is, Walshy, that might be a RAM killer.
     
  7. Offline

    timtower Administrator Administrator Moderator

    @Tecno_Wizard Database might be a speed killer, it depends on the data and how much it is used for what to use.
     
  8. Offline

    mythbusterma

    @GiantDwarf01

    You can make HashMaps of any item, so why don't you make your own class, then make HashMaps of that?
     
  9. Offline

    Konato_K

    @GiantDwarf01 Just adding another alternative, but SQLite is a database and does not need a server to run, it's local, is fast, and considering you're using SQL syntax it should be easier to move to SQLite since you may only have to change a few things here and there.
     
  10. Offline

    mythbusterma

    @Konato_K

    It's still significantly slower than using FileConfiguration.
     
  11. Offline

    Konato_K

    @mythbusterma If he wants a database I assume he needs thousands or more records, which keeping in a file configuration may not be a good idea.
     
  12. Offline

    boomboompower

    @Konato_K look at essentials. I doubt it will be as big is that, if he was making a large server with 10k people on it every day (Like Hypixel) then, it wouldn't be a good idea to use FileConfiguration
     
  13. Offline

    mythbusterma

  14. Offline

    Tecno_Wizard

    Here's what I do for data storage. With a lot of my newer plugins (not on bukkit dev), I am using a generic system I made this summer. So far it's designed for JSON only (JSON.simple is built into craftbukkit and is significantly faster at parsing vs YAML). As a player logs in, the player's file is loaded into the ram. If a player is offline and their file is requested, it is loaded into the cache for 5 minutes, then if not used again, disposed. Once a player logs off, the changes to the file are flushed and the file is discarded from the ram. Every 10 mins all data is flushed async.
     
    DoggyCodeâ„¢ likes this.
  15. Offline

    Konato_K

    @boomboompower Essentials uses a single file for each player, this "fixes" the problem.

    @mythbusterma Personal experience, I have seen plugins "reset" all their data once they reach some thousand amount of entries, an example of this has been Pex, which seemed to reset when it had a lot of players in it's configuration file.
     
  16. Offline

    mythbusterma

    @Konato_K

    That's a programatical error, not an issue with the method of storing itself.
     
    Konato_K likes this.
  17. Offline

    GiantDwarf01

    Thank you everyone for your help. I'll probably try some of the methods and see which one is best after testing. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page