Solved Efficiency Assistance/Question

Discussion in 'Plugin Development' started by FerusGrim, Oct 21, 2014.

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

    FerusGrim

    Hey!

    I'm developing a plugin which is fairly simple, but there's a slightly complex logical situation of how to keep the Server/Source data consistent with each other.

    I've created a Gist which outlines the current method, as well as the source code for said Method.

    The Gist contains the MySQL Manager, however, ManagerTypes are modular, and easily swapped around. Currently, the only thing each ManagerType contributes to this method is the actual grabbing of a list of whitelisted users, via Manager#getWhitelistFromSource. The rest is handled within the ManagerBase.

    TL;DR, take a look at the link above, and help me think of a better way to do this!
     
  2. FerusGrim

    Maybe I'm misunderstanding your current method, but couldn't you basically have it so that when the plugin starts, it caches the whitelist from source. Every time the list is altered through a command (and ensure that the list is actually altered, not just a player adding someone already on the list or removing someone who isn't there) push the update to source. Then, every X amount of time, discard the local copy and pull from source again.
     
  3. Offline

    FerusGrim

    AdamQpzm
    When the plugin starts, it does cache Source to Server.

    -> Plugin Starts
    -> Load Source to Server
    -> Store cache in ManagerBase (whiteList)
    -> In-Game commands remove/add via additionList and removalList.
    -> ServerSync syncs these additions/removals to the Source, and then merge into the whiteList, and then get cleared, so the process can be repeated in the future.

    However, certain sources (such as MySQL) have the potential to be modified from sources besides in-game commands, which is where comparing a pull from Manager#getWhitelistFromSource and Manager#getWhitelist comes from.
     
  4. FerusGrim I'm just wondering if there's a need for the removalList or additionList - why not just update as soon as the user changes the whitelist through commands? This is based on the assumption that users wouldn't spend their time constantly changing the whitelist for no apparent reasons. It would be a strange case for those who did and complained about efficiency problems. :)

    And then you'd account for the external changes with the current re-grabbing method.
     
  5. Offline

    FerusGrim

    AdamQpzm
    That's a good point... I could do all the normal work, and then asynchronously update the Source... I'll probably look into that. :)

    Thinking on it, though, I still have to compensate for Sources that are modified without in-game methods.

    Any suggestions for improving that, AdamQpzm?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
    AdamQpzm likes this.
  6. FerusGrim As said, just get the list again every X amount of time, best way to do it really :p
     
    FerusGrim likes this.
  7. Offline

    FerusGrim


    Right, right. Stick with this, then?:
    -> Iterate through whiteList.
    -> If Source doesn't contain a UUID from whiteList, remove it from whiteList.
    -> Loop through Source
    -> If whiteList doesn't contain UUID from Source, add it to whiteList.
     
  8. FerusGrim For when updating from source? Might as well just discard whatever you currently have and remake from source, since the source is meant to be in sync with the server's command-based changes.
     
  9. Offline

    FerusGrim

    AdamQpzm
    *eye twitch*

    Well, that reduces problems.
     
    AdamQpzm likes this.
Thread Status:
Not open for further replies.

Share This Page