Serialize a Object or save in DB?

Discussion in 'Plugin Development' started by silthus, Sep 12, 2011.

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



    I am not sure wether I should serialize my Object data or save certain key aspects in a Database? What is more efficent?

    What I want to store is a Mapping of a dungeon which contains refrences to WorldGuard Objects/Snapshots (not sure there yet) and some data for the User.
    Or is there anyway to store that data in a neat .yml without having to go through all the trouble and defining RootPath and such?

    Thanks in advance.
  2. Offline


    I would personally go with serialization, since it doesn't require any extra libraries (and bukkit's Persistence isn't really and option for me ...).
    A YAML file would also be an option, since bukkit offers the Configuration class for that.
    You don't need to do that much, just something like that:
    Configuration c = new Configuration(yourFile);
    c.setProperty("mydata1", "foobar");
    c.setProperty("whatever.subthing", "fooooo");
    c.setProperty("whatever.otherthing", 42);;
  3. Offline


    Mapping out individual parameters of the object to a db table has the advantage of being able to query for those values later without having to rebuild the whole object.

    If that's not at all useful to you I'd just go with serialization.
Thread Status:
Not open for further replies.

Share This Page