Solved Is this necessary?

Discussion in 'Plugin Development' started by Wizardo367, Mar 6, 2014.

Thread Status:
Not open for further replies.
  1. Hello people, the plugin I'm currently working on is heavily dependant on MySQL and uses cache to store data, however since the database is only updated periodically the loss of data is possible in the event of a sudden shut-down.

    The solution I've come up with is to serialise the data and constantly write it to a file, every 30 seconds or so any changes to the cache are read + written to the database and the files are wiped. The files will only ever be read on start-up. Now is all of this really necessary if 30 seconds or more worth of data is being stored, (this can be quite a lot of data on large servers) or won't it matter because large servers aren't prone to sudden shut-downs.

    Plus I don't wan't mis-matching data, e.g. the plugin saves the changes but the server itself never saved, meaning players have been charged for the items but don't actually have them.

    Any help regarding this topic is appreciated. :D
     
  2. Offline

    Bart

    I wouldn't bother writing it to a file if you're pushing to the database every 5 minutes + onDisable. It's only 5 minutes of progress so I guess it does depend on what you are trying to store.
     
  3. The plugin is basically a server store and the data is any changes that have been made to the item's properties e.g. price as well as sign placements, enchantment property modifications and most importantly transaction data. The transaction data is the main data that will be stored as the others will only by modified every now and then. Would this have any effect on performance? The records are quite small.
     
  4. Offline

    Bart

    I would push every 30 seconds (with checks to make sure there is actually new data to push) but when you write to a file you come into concurrency issues - one server could have updated 'xx' to 5 but the file says 3 so it gets put back to 3 etc.
     
  5. I'm not sure what you mean by the server and files having different numbers as the plugin only uses the file for restoring data, all item properties are dependant on the cache and any price changes will have no effect on the records being kept. Plus what do you mean by "push every 30 seconds" do you mean push the data to the file or push the data to the database?
     
  6. Offline

    Bart

    Push it to the database
     
  7. K, thanks for your help. :D
     
Thread Status:
Not open for further replies.

Share This Page