= Updated db upkeep frequency
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import core.DatabaseManager;
|
import core.DatabaseManager;
|
||||||
import core.LocCommands;
|
import core.LocCommands;
|
||||||
import core.LocStrings;
|
import core.LocStrings;
|
||||||
@@ -79,13 +81,20 @@ public class Superintendent
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Integer delayTimerReset = 5;
|
||||||
|
private static AtomicInteger delayTimerCurrent = new AtomicInteger(delayTimerReset);
|
||||||
|
|
||||||
// This is for stuff that we need to do on a regular basis, but don't
|
// This is for stuff that we need to do on a regular basis, but don't
|
||||||
// necessarily want running at all points in time.
|
// necessarily want running at all points in time.
|
||||||
// Happens just after the command / plugin runs.
|
// Happens just after the command / plugin runs.
|
||||||
public static boolean PerCommandUpkeepPost(JDA bot, DatabaseManager databaseManager)
|
public static boolean PerCommandUpkeepPost(JDA bot, DatabaseManager databaseManager)
|
||||||
{
|
{
|
||||||
// Upkeep database
|
// Upkeep database lazily on occasion
|
||||||
databaseManager.Upkeep();
|
if(delayTimerCurrent.decrementAndGet() < 0)
|
||||||
|
{
|
||||||
|
databaseManager.Upkeep();
|
||||||
|
delayTimerCurrent.set(delayTimerReset);
|
||||||
|
}
|
||||||
|
|
||||||
// Update command-specific
|
// Update command-specific
|
||||||
RPManager.Upkeep(bot);
|
RPManager.Upkeep(bot);
|
||||||
|
|||||||
Reference in New Issue
Block a user