Rename method

This commit is contained in:
Bea 2022-12-20 22:49:20 +01:00
parent d09c59996b
commit 161c91b45d
3 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ public class Cache
private static LocalDateTime startupTime = null; private static LocalDateTime startupTime = null;
// the scheduler that should always be used when running a scheduled task. // the scheduler that should always be used when running a scheduled task.
private final static ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); // todo: try-with-resources private final static ScheduledExecutorService taskScheduler = Executors.newSingleThreadScheduledExecutor(); // todo: try-with-resources
private final static String execPath = System.getProperty("user.dir"); private final static String execPath = System.getProperty("user.dir");
private static final String botName = "Hideko"; private static final String botName = "Hideko";
@ -322,8 +322,8 @@ public class Cache
loveCalculatorValues.remove(userId2 + "|" + userId1); loveCalculatorValues.remove(userId2 + "|" + userId1);
} }
public static ScheduledExecutorService getScheduler() { public static ScheduledExecutorService getTaskScheduler() {
return scheduler; return taskScheduler;
} }
} }

View File

@ -178,7 +178,7 @@ public class HidekoBot
} }
// start scheduled runnables // start scheduled runnables
ScheduledExecutorService scheduler = Cache.getScheduler(); ScheduledExecutorService scheduler = Cache.getTaskScheduler();
ExpiredMessageTask expiredMessageTask = new ExpiredMessageTask(); ExpiredMessageTask expiredMessageTask = new ExpiredMessageTask();
scheduler.scheduleAtFixedRate(expiredMessageTask, 5, 5, TimeUnit.SECONDS); //every 5 seconds scheduler.scheduleAtFixedRate(expiredMessageTask, 5, 5, TimeUnit.SECONDS); //every 5 seconds
HeartBeatTask heartBeatTask = new HeartBeatTask(); HeartBeatTask heartBeatTask = new HeartBeatTask();

View File

@ -20,7 +20,7 @@ public class LoveCalculator
{ {
loveAmount = RandomUtil.getRandomNumber(0, 100); loveAmount = RandomUtil.getRandomNumber(0, 100);
Cache.cacheLoveCalculatorValue(userId1, userId2, loveAmount); Cache.cacheLoveCalculatorValue(userId1, userId2, loveAmount);
Cache.getScheduler().schedule(() -> Cache.getTaskScheduler().schedule(() ->
Cache.removeLoveCalculatorValue(userId1, userId2), 10, TimeUnit.MINUTES); Cache.removeLoveCalculatorValue(userId1, userId2), 10, TimeUnit.MINUTES);
} }