Global Data linking

Discussion in 'Programming' started by Gerolmed, Jan 10, 2018.

Thread Status:
Not open for further replies.
  1. I have a MySQL Database sto ring the money of a player. The problem is I'm accessing the database at the same time from spigot, bungee cord and the website. Does anyone have a good idea on how to spread update notifies and prevent inconsistency?
  2. Honestly, the only option I can think of is just checking every 10 seconds or so. If the table is huge you could have another table storing if a players money has changed and if it has mark the service as "updated." If all services but one has updated when that service updates delete that entry.

    P.S. I have never tested or researched this subject. I have no idea if this is the best way to do it.
  3. I've thought about that as well but how will I know of all servers have updated?
  4. Heres what the table would look like. When a server updates it changes there entry to true. When all three are true then the entry deletes. In this example when Server B updates Player 1 and sees that after they are true all the entrys are true then it would delete that entry. Also, you would have to make sure that it goes in order so if a player gets money very quickly it still works.

  5. Not the best way to design a database. What do you do if a additional server gets added? Recreate the table and fill the data again?
  6. Why not check out redis? (pub/sub)
    • Like Like x 2
    • Agree Agree x 2
    • Like Like x 1
  7. This. Connecting your server to some kind of event bus for pub-subbing would be a clean solution.
    • Agree Agree x 1
  8. I will look at that. It sounds quite interesting.
  9. Yahh. I have never done something like this before so that was just my best guess.
    • Friendly Friendly x 1
  10. Yes that is exactly your problem... Don't. Only access the data from one source when it is needed. If the players balance changes in spigot, only access it in spigot and change the value one time. If it is changed via your website, only access it via the website code and change the value one time.
    There is no point updating the value 3 different times 3 different ways with the same value. When any of the 3 go to read from it, they will all get the correct newly updated value, that's what a database is for.
  11. That is what i was doing... There is just the Problem to notify the other programs of the change
Thread Status:
Not open for further replies.

Share This Page