I’m working on a new plugin (currently just designing how data will be stored) & i think it’s probably going to work using a database of rows that equal actions & every 3 or 5 minutes it’ll go through a few of the rows & do their action, this is because the actions are mostly just incrementing values & i don’t want multiple actions being preformed on the same database row as i’m guessing it could result in only one update going through by overwriting the other update.
Why do i think i need to worry about this: my plugin will be triggering & updating the same row(s) within seconds of each other very often & in unpredictable & changing frequencies.
I do already have a lot of ideas on how to make this database of actions that gets run consistently:
Flow with trigger ‘every minute’
because it can run a minute early or late, track in a database row the last time run & if it’s been more then 60 seconds then run again, if not don’t run & wait to next trigger.
Will use ‘get rows’ block i guess to go through them, check time every iteration & compare to time when flow started, if time is close (maybe 2 to 3 seconds) to 15 seconds since flow started (no way to know if bot has premium or not as far as i know but maybe i can make it a plugin setting) to exit flow as to not exit flow mid-iteration.
One big problem is with users spamming actions like triggers ‘reaction add’ & then ‘reaction remove’ which i don’t want to clog up the upcoming action list database. i could just make it search for rows for ‘reaction add’ & delete them when getting the trigger ‘reaction remove’ but that would still very rarely delete a row when it’s currently being acted on & then the update that it should be reverted never gets acted on but this would be very very rare so it’s probably no issue, the bigger issue with this idea is that it’s pretty complex but probably still what i’ll go with.
This topic/post isn’t looking for the solution & won’t be closed for such. This is just for discussion, ideas & any advice on this so if you have any thoughts then they’d likely be useful for me & maybe even others to hear.
Hope this all makes sense, sorry for any mistakes i might have made & i can try to clarify anything if anyone really needs me to.