From 95af3f5f8baac8cba3fbb1baefcf3b961b314967 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Fri, 12 Feb 2021 10:56:48 +0200 Subject: [PATCH] Removed JSONCache and its invalidation uses --- .../bukkit/PlayerOnlineListener.java | 6 - .../plan/modules/bukkit/BukkitTaskModule.java | 5 - .../bungee/PlayerOnlineListener.java | 25 --- .../plan/modules/bungee/BungeeTaskModule.java | 5 - .../delivery/rendering/pages/DebugPage.java | 18 -- .../delivery/webserver/WebServerSystem.java | 3 - .../plan/delivery/webserver/cache/DataID.java | 2 +- .../delivery/webserver/cache/JSONCache.java | 179 ------------------ .../plan/extension/ExtensionSvc.java | 4 - .../events/PlayerRegisterTransaction.java | 4 - .../events/SessionEndTransaction.java | 17 -- .../webserver/cache/JSONCacheTest.java | 114 ----------- .../nukkit/PlayerOnlineListener.java | 6 - .../plan/modules/nukkit/NukkitTaskModule.java | 5 - .../sponge/PlayerOnlineListener.java | 6 - .../plan/modules/sponge/SpongeTaskModule.java | 5 - .../velocity/PlayerOnlineListener.java | 26 --- .../modules/velocity/VelocityTaskModule.java | 5 - 18 files changed, 1 insertion(+), 434 deletions(-) delete mode 100644 Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/JSONCache.java delete mode 100644 Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/cache/JSONCacheTest.java diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java index 177f401bd..966d4f780 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/PlayerOnlineListener.java @@ -19,8 +19,6 @@ package com.djrapitops.plan.gathering.listeners.bukkit; import com.djrapitops.plan.delivery.domain.Nickname; import com.djrapitops.plan.delivery.domain.keys.SessionKeys; import com.djrapitops.plan.delivery.export.Exporter; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionSvc; import com.djrapitops.plan.gathering.cache.NicknameCache; @@ -152,8 +150,6 @@ public class PlayerOnlineListener implements Listener { UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); long time = System.currentTimeMillis(); - JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); - JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); BukkitAFKListener.AFK_TRACKER.performedAction(playerUUID, time); @@ -216,8 +212,6 @@ public class PlayerOnlineListener implements Listener { String playerName = player.getName(); UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); - JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); BukkitAFKListener.AFK_TRACKER.loggedOut(playerUUID, time); diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java index 7cc08b12c..89f50a802 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/modules/bukkit/BukkitTaskModule.java @@ -17,7 +17,6 @@ package com.djrapitops.plan.modules.bukkit; import com.djrapitops.plan.TaskSystem; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.delivery.webserver.cache.JSONFileStorage; import com.djrapitops.plan.extension.ExtensionServerDataUpdater; import com.djrapitops.plan.gathering.ShutdownHook; @@ -59,10 +58,6 @@ public interface BukkitTaskModule { @IntoSet TaskSystem.Task bindDBCleanTask(DBCleanTask cleanTask); - @Binds - @IntoSet - TaskSystem.Task bindJSONCacheCleanTask(JSONCache.CleanTask cleanTask); - @Binds @IntoSet TaskSystem.Task bindRamAndCpuTask(SystemUsageBuffer.RamAndCpuTask ramAndCpuTask); diff --git a/Plan/bungeecord/src/main/java/com/djrapitops/plan/gathering/listeners/bungee/PlayerOnlineListener.java b/Plan/bungeecord/src/main/java/com/djrapitops/plan/gathering/listeners/bungee/PlayerOnlineListener.java index 5d0df3b05..89b312af0 100644 --- a/Plan/bungeecord/src/main/java/com/djrapitops/plan/gathering/listeners/bungee/PlayerOnlineListener.java +++ b/Plan/bungeecord/src/main/java/com/djrapitops/plan/gathering/listeners/bungee/PlayerOnlineListener.java @@ -18,8 +18,6 @@ package com.djrapitops.plan.gathering.listeners.bungee; import com.djrapitops.plan.delivery.domain.keys.SessionKeys; import com.djrapitops.plan.delivery.export.Exporter; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionSvc; import com.djrapitops.plan.gathering.cache.SessionCache; @@ -124,10 +122,6 @@ public class PlayerOnlineListener implements Listener { } UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidateMatching(DataID.SERVER_OVERVIEW); - JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID); - JSONCache.invalidate(DataID.SERVERS); - JSONCache.invalidate(DataID.SESSIONS); } @EventHandler(priority = EventPriority.NORMAL) @@ -156,23 +150,6 @@ public class PlayerOnlineListener implements Listener { if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } - processing.submit(() -> { - JSONCache.invalidateMatching( - DataID.SERVER_OVERVIEW, - DataID.SESSIONS, - DataID.GRAPH_WORLD_PIE, - DataID.GRAPH_PUNCHCARD, - DataID.KILLS, - DataID.ONLINE_OVERVIEW, - DataID.SESSIONS_OVERVIEW, - DataID.PVP_PVE, - DataID.GRAPH_UNIQUE_NEW, - DataID.GRAPH_CALENDAR - ); - UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID); - JSONCache.invalidate(DataID.SERVERS); - }); } @EventHandler(priority = EventPriority.HIGHEST) @@ -198,7 +175,5 @@ public class PlayerOnlineListener implements Listener { if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } - - JSONCache.invalidate(DataID.SERVERS); } } diff --git a/Plan/bungeecord/src/main/java/com/djrapitops/plan/modules/bungee/BungeeTaskModule.java b/Plan/bungeecord/src/main/java/com/djrapitops/plan/modules/bungee/BungeeTaskModule.java index 5a6642f16..c155abf78 100644 --- a/Plan/bungeecord/src/main/java/com/djrapitops/plan/modules/bungee/BungeeTaskModule.java +++ b/Plan/bungeecord/src/main/java/com/djrapitops/plan/modules/bungee/BungeeTaskModule.java @@ -17,7 +17,6 @@ package com.djrapitops.plan.modules.bungee; import com.djrapitops.plan.TaskSystem; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.delivery.webserver.cache.JSONFileStorage; import com.djrapitops.plan.extension.ExtensionServerDataUpdater; import com.djrapitops.plan.gathering.timed.BungeePingCounter; @@ -57,10 +56,6 @@ public interface BungeeTaskModule { @IntoSet TaskSystem.Task bindDBCleanTask(DBCleanTask cleanTask); - @Binds - @IntoSet - TaskSystem.Task bindJSONCacheCleanTask(JSONCache.CleanTask cleanTask); - @Binds @IntoSet TaskSystem.Task bindRamAndCpuTask(SystemUsageBuffer.RamAndCpuTask ramAndCpuTask); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/DebugPage.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/DebugPage.java index a205e0a10..c52458cf0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/DebugPage.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/pages/DebugPage.java @@ -24,7 +24,6 @@ import com.djrapitops.plan.delivery.rendering.html.Contributors; import com.djrapitops.plan.delivery.rendering.html.Html; import com.djrapitops.plan.delivery.rendering.html.icon.Icon; import com.djrapitops.plan.delivery.rendering.html.structure.TabsElement; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.gathering.cache.SessionCache; import com.djrapitops.plan.gathering.domain.Session; import com.djrapitops.plan.identification.ServerInfo; @@ -119,7 +118,6 @@ public class DebugPage implements Page { private String createCacheContent() { StringBuilder content = new StringBuilder(); appendResourceCache(content); - appendJSONCache(content); appendSessionCache(content); return content.toString(); } @@ -140,22 +138,6 @@ public class DebugPage implements Page { } } - private void appendJSONCache(StringBuilder content) { - try { - content.append("
### Cached JSON:

"); - List cacheKeys = JSONCache.getCachedIDs(); - if (cacheKeys.isEmpty()) { - content.append("Empty"); - } - for (String cacheKey : cacheKeys) { - content.append("- ").append(cacheKey).append("
"); - } - content.append("
"); - } catch (Exception e) { - errorLogger.log(L.WARN, e, ErrorContext.builder().related("/debug page access, JSON cache").build()); - } - } - private void appendSessionCache(StringBuilder content) { try { content.append("
### Session Cache:

"); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServerSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServerSystem.java index f33f85489..5f9e89c92 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServerSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServerSystem.java @@ -18,7 +18,6 @@ package com.djrapitops.plan.delivery.webserver; import com.djrapitops.plan.SubSystem; import com.djrapitops.plan.delivery.web.ResourceService; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import javax.inject.Inject; import javax.inject.Singleton; @@ -63,8 +62,6 @@ public class WebServerSystem implements SubSystem { @Override public void disable() { webServer.disable(); - JSONCache.invalidateAll(); - JSONCache.cleanUp(); } public WebServer getWebServer() { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java index 2900fee63..32a3938e4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/DataID.java @@ -19,7 +19,7 @@ package com.djrapitops.plan.delivery.webserver.cache; import java.util.UUID; /** - * Enum for different JSON data entries that can be stored in {@link JSONCache}. + * Enum for different JSON data entries that can be stored in cache. * * @author Rsl1122 */ diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/JSONCache.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/JSONCache.java deleted file mode 100644 index eec4cf96c..000000000 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/cache/JSONCache.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * This file is part of Player Analytics (Plan). - * - * Plan is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License v3 as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Plan is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Plan. If not, see . - */ -package com.djrapitops.plan.delivery.webserver.cache; - -import com.djrapitops.plan.TaskSystem; -import com.djrapitops.plan.delivery.web.resolver.MimeType; -import com.djrapitops.plan.delivery.web.resolver.Response; -import com.djrapitops.plan.delivery.webserver.resolver.json.RootJSONResolver; -import com.djrapitops.plan.storage.file.ResourceCache; -import com.djrapitops.plugin.api.TimeAmount; -import com.djrapitops.plugin.task.RunnableFactory; -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; -import org.apache.commons.lang3.StringUtils; - -import javax.inject.Inject; -import javax.inject.Singleton; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -/** - * Cache for any JSON data sent via {@link RootJSONResolver}. - * - * @author Rsl1122 - */ -@Deprecated -public class JSONCache { - - private static final Cache cache = Caffeine.newBuilder() - .expireAfterAccess(2, TimeUnit.MINUTES) - .build(); - - private JSONCache() { - // Static class - } - - @Deprecated - public static Response getOrCache(String identifier, Supplier jsonResponseSupplier) { - byte[] found = cache.getIfPresent(identifier); - if (found == null) { - Response response = jsonResponseSupplier.get(); - cache.put(identifier, response.getBytes()); - return response; - } - return Response.builder() - .setMimeType(MimeType.JSON) - .setContent(found) - .build(); - } - - @Deprecated - public static String getOrCacheString(DataID dataID, UUID serverUUID, Supplier stringSupplier) { - String identifier = dataID.of(serverUUID); - byte[] found = cache.getIfPresent(identifier); - if (found == null) { - String result = stringSupplier.get(); - cache.put(identifier, result.getBytes(StandardCharsets.UTF_8)); - return result; - } - return new String(found, StandardCharsets.UTF_8); - } - - @Deprecated - public static Response getOrCache(DataID dataID, Supplier objectSupplier) { - return getOrCache(dataID.name(), () -> Response.builder() - .setMimeType(MimeType.JSON) - .setJSONContent(objectSupplier.get()) - .build()); - } - - @Deprecated - public static Response getOrCache(DataID dataID, UUID serverUUID, Supplier objectSupplier) { - return getOrCache(dataID.of(serverUUID), () -> Response.builder() - .setMimeType(MimeType.JSON) - .setJSONContent(objectSupplier.get()) - .build()); - } - - @Deprecated - public static void invalidate(String identifier) { - cache.invalidate(identifier); - } - - @Deprecated - public static void invalidate(DataID dataID) { - invalidate(dataID.name()); - } - - @Deprecated - public static void invalidate(UUID serverUUID, DataID... dataIDs) { - for (DataID dataID : dataIDs) { - invalidate(dataID.of(serverUUID)); - } - } - - @Deprecated - public static void invalidate(DataID dataID, UUID serverUUID) { - invalidate(dataID.of(serverUUID)); - } - - @Deprecated - public static void invalidateMatching(DataID... dataIDs) { - Set toInvalidate = Arrays.stream(dataIDs) - .map(DataID::name) - .collect(Collectors.toSet()); - for (String identifier : cache.asMap().keySet()) { - for (String identifierToInvalidate : toInvalidate) { - if (StringUtils.startsWith(identifier, identifierToInvalidate)) { - invalidate(identifier); - } - } - } - } - - @Deprecated - public static void invalidateMatching(DataID dataID) { - String toInvalidate = dataID.name(); - for (String identifier : cache.asMap().keySet()) { - if (StringUtils.startsWith(identifier, toInvalidate)) { - invalidate(identifier); - } - } - } - - @Deprecated - public static void invalidateAll() { - cache.invalidateAll(); - } - - @Deprecated - public static void cleanUp() { - cache.cleanUp(); - } - - @Deprecated - public static List getCachedIDs() { - List identifiers = new ArrayList<>(cache.asMap().keySet()); - Collections.sort(identifiers); - return identifiers; - } - - @Singleton - public static class CleanTask extends TaskSystem.Task { - - @Inject - public CleanTask() { - // Dagger requires inject constructor - } - - @Override - public void run() { - cleanUp(); - ResourceCache.cleanUp(); - } - - @Override - public void register(RunnableFactory runnableFactory) { - long minute = TimeAmount.toTicks(1, TimeUnit.MINUTES); - runnableFactory.create(null, this).runTaskTimerAsynchronously(minute, minute); - } - } -} \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java index 0505e3321..59d8f9e49 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/ExtensionSvc.java @@ -17,8 +17,6 @@ package com.djrapitops.plan.extension; import com.djrapitops.plan.DebugChannels; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.exceptions.DataExtensionMethodCallException; import com.djrapitops.plan.extension.implementation.CallerImplementation; import com.djrapitops.plan.extension.implementation.ExtensionRegister; @@ -197,8 +195,6 @@ public class ExtensionSvc implements ExtensionService { updateServerValues(gatherer, event); } UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidate(DataID.EXTENSION_NAV, serverUUID); - JSONCache.invalidate(DataID.EXTENSION_TABS, serverUUID); } public void updateServerValues(ProviderValueGatherer gatherer, CallEvents event) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java index 6fc11c904..8c691cadb 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java @@ -16,8 +16,6 @@ */ package com.djrapitops.plan.storage.database.transactions.events; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.exceptions.database.DBOpException; import com.djrapitops.plan.gathering.cache.SessionCache; import com.djrapitops.plan.storage.database.queries.DataStoreQueries; @@ -57,8 +55,6 @@ public class PlayerRegisterTransaction extends Transaction { SessionCache.getCachedSession(playerUUID).ifPresent(session -> session.setAsFirstSessionIfMatches(registerDate)); } execute(DataStoreQueries.updatePlayerName(playerUUID, playerName)); - - JSONCache.invalidateMatching(DataID.PLAYERS); } private void insertUser(long registerDate) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java index 4089438fb..c0a223eb1 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/SessionEndTransaction.java @@ -16,9 +16,6 @@ */ package com.djrapitops.plan.storage.database.transactions.events; -import com.djrapitops.plan.delivery.domain.keys.SessionKeys; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.gathering.domain.Session; import com.djrapitops.plan.storage.database.queries.DataStoreQueries; import com.djrapitops.plan.storage.database.transactions.Transaction; @@ -39,19 +36,5 @@ public class SessionEndTransaction extends Transaction { @Override protected void performOperations() { execute(DataStoreQueries.storeSession(session)); - - session.getValue(SessionKeys.SERVER_UUID) - .ifPresent(serverUUID -> JSONCache.invalidate( - serverUUID, - DataID.SESSIONS, - DataID.GRAPH_WORLD_PIE, - DataID.GRAPH_PUNCHCARD, - DataID.KILLS, - DataID.ONLINE_OVERVIEW, - DataID.SESSIONS_OVERVIEW, - DataID.PVP_PVE, - DataID.GRAPH_UNIQUE_NEW, - DataID.GRAPH_CALENDAR - )); } } \ No newline at end of file diff --git a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/cache/JSONCacheTest.java b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/cache/JSONCacheTest.java deleted file mode 100644 index ab8363999..000000000 --- a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/cache/JSONCacheTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of Player Analytics (Plan). - * - * Plan is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License v3 as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Plan is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Plan. If not, see . - */ -package com.djrapitops.plan.delivery.webserver.cache; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.UUID; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests JSONCache invalidation. - * - * @author Rsl1122 - */ -class JSONCacheTest { - - private static final String CACHED = "Cached"; - private static final DataID TEST_ID = DataID.SESSIONS; - private static final UUID TEST_UUID = UUID.randomUUID(); - - @BeforeEach - void cleanCache() { - JSONCache.invalidateAll(); - } - - @Test - void cachedByDataIDName() { - JSONCache.getOrCache(TEST_ID, () -> CACHED); - assertContains(); - } - - private void assertContains() { - List cached = JSONCache.getCachedIDs(); - assertTrue(cached.contains(TEST_ID.name())); - } - - private void assertNotContains() { - List cached = JSONCache.getCachedIDs(); - assertFalse(cached.contains(TEST_ID.name())); - } - - @Test - void invalidatedByExactDataID() { - cachedByDataIDName(); - JSONCache.invalidate(TEST_ID); - assertNotContains(); - } - - @Test - void allInvalidated() { - cachedByDataIDName(); - JSONCache.invalidateAll(); - assertNotContains(); - } - - @Test - void cachedByServerUUID() { - JSONCache.getOrCache(TEST_ID, TEST_UUID, () -> CACHED); - assertContainsUUID(); - } - - private void assertContainsUUID() { - List cached = JSONCache.getCachedIDs(); - assertTrue(cached.contains(TEST_ID.of(TEST_UUID))); - } - - private void assertNotContainsUUID() { - List cached = JSONCache.getCachedIDs(); - assertFalse(cached.contains(TEST_ID.of(TEST_UUID))); - } - - @Test - void invalidateByServerUUID() { - cachedByServerUUID(); - JSONCache.invalidate(TEST_ID, TEST_UUID); - assertNotContainsUUID(); - } - - @Test - void invalidateMatchingByID() { - cachedByDataIDName(); - cachedByServerUUID(); - JSONCache.invalidateMatching(TEST_ID); - assertNotContains(); - assertNotContainsUUID(); - } - - @Test - void invalidateMatchingByIDVarargs() { - cachedByDataIDName(); - cachedByServerUUID(); - JSONCache.invalidateMatching(TEST_ID, TEST_ID); - assertNotContains(); - assertNotContainsUUID(); - } -} \ No newline at end of file diff --git a/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java b/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java index 2dc7321fa..fa35ea45e 100644 --- a/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java +++ b/Plan/nukkit/src/main/java/com/djrapitops/plan/gathering/listeners/nukkit/PlayerOnlineListener.java @@ -27,8 +27,6 @@ import cn.nukkit.event.player.PlayerQuitEvent; import com.djrapitops.plan.delivery.domain.Nickname; import com.djrapitops.plan.delivery.domain.keys.SessionKeys; import com.djrapitops.plan.delivery.export.Exporter; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionSvc; import com.djrapitops.plan.gathering.cache.NicknameCache; @@ -150,8 +148,6 @@ public class PlayerOnlineListener implements Listener { UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); long time = System.currentTimeMillis(); - JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); - JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); NukkitAFKListener.AFK_TRACKER.performedAction(playerUUID, time); @@ -217,8 +213,6 @@ public class PlayerOnlineListener implements Listener { if (playerUUID == null) return; // Can be null when player is not signed in to xbox live UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); - JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); NukkitAFKListener.AFK_TRACKER.loggedOut(playerUUID, time); diff --git a/Plan/nukkit/src/main/java/com/djrapitops/plan/modules/nukkit/NukkitTaskModule.java b/Plan/nukkit/src/main/java/com/djrapitops/plan/modules/nukkit/NukkitTaskModule.java index 3e4e8a357..3eb1a7259 100644 --- a/Plan/nukkit/src/main/java/com/djrapitops/plan/modules/nukkit/NukkitTaskModule.java +++ b/Plan/nukkit/src/main/java/com/djrapitops/plan/modules/nukkit/NukkitTaskModule.java @@ -18,7 +18,6 @@ package com.djrapitops.plan.modules.nukkit; import cn.nukkit.level.Level; import com.djrapitops.plan.TaskSystem; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.delivery.webserver.cache.JSONFileStorage; import com.djrapitops.plan.extension.ExtensionServerDataUpdater; import com.djrapitops.plan.gathering.ShutdownHook; @@ -59,10 +58,6 @@ public interface NukkitTaskModule { @IntoSet TaskSystem.Task bindDBCleanTask(DBCleanTask cleanTask); - @Binds - @IntoSet - TaskSystem.Task bindJSONCacheCleanTask(JSONCache.CleanTask cleanTask); - @Binds @IntoSet TaskSystem.Task bindRamAndCpuTask(SystemUsageBuffer.RamAndCpuTask ramAndCpuTask); diff --git a/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java b/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java index b4d1d05df..a9809fe5c 100644 --- a/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java +++ b/Plan/sponge/src/main/java/com/djrapitops/plan/gathering/listeners/sponge/PlayerOnlineListener.java @@ -19,8 +19,6 @@ package com.djrapitops.plan.gathering.listeners.sponge; import com.djrapitops.plan.delivery.domain.Nickname; import com.djrapitops.plan.delivery.domain.keys.SessionKeys; import com.djrapitops.plan.delivery.export.Exporter; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionSvc; import com.djrapitops.plan.gathering.cache.NicknameCache; @@ -154,8 +152,6 @@ public class PlayerOnlineListener { UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); long time = System.currentTimeMillis(); - JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); - JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); SpongeAFKListener.AFK_TRACKER.performedAction(playerUUID, time); @@ -219,8 +215,6 @@ public class PlayerOnlineListener { String playerName = player.getName(); UUID playerUUID = player.getUniqueId(); UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidate(DataID.SERVER_OVERVIEW, serverUUID); - JSONCache.invalidate(DataID.GRAPH_PERFORMANCE, serverUUID); SpongeAFKListener.AFK_TRACKER.loggedOut(playerUUID, time); diff --git a/Plan/sponge/src/main/java/com/djrapitops/plan/modules/sponge/SpongeTaskModule.java b/Plan/sponge/src/main/java/com/djrapitops/plan/modules/sponge/SpongeTaskModule.java index c08d6bce2..9aa3a6c7e 100644 --- a/Plan/sponge/src/main/java/com/djrapitops/plan/modules/sponge/SpongeTaskModule.java +++ b/Plan/sponge/src/main/java/com/djrapitops/plan/modules/sponge/SpongeTaskModule.java @@ -17,7 +17,6 @@ package com.djrapitops.plan.modules.sponge; import com.djrapitops.plan.TaskSystem; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.delivery.webserver.cache.JSONFileStorage; import com.djrapitops.plan.extension.ExtensionServerDataUpdater; import com.djrapitops.plan.gathering.ShutdownHook; @@ -59,10 +58,6 @@ public interface SpongeTaskModule { @IntoSet TaskSystem.Task bindDBCleanTask(DBCleanTask cleanTask); - @Binds - @IntoSet - TaskSystem.Task bindJSONCacheCleanTask(JSONCache.CleanTask cleanTask); - @Binds @IntoSet TaskSystem.Task bindRamAndCpuTask(SystemUsageBuffer.RamAndCpuTask ramAndCpuTask); diff --git a/Plan/velocity/src/main/java/com/djrapitops/plan/gathering/listeners/velocity/PlayerOnlineListener.java b/Plan/velocity/src/main/java/com/djrapitops/plan/gathering/listeners/velocity/PlayerOnlineListener.java index f4cc648e0..d80e83575 100644 --- a/Plan/velocity/src/main/java/com/djrapitops/plan/gathering/listeners/velocity/PlayerOnlineListener.java +++ b/Plan/velocity/src/main/java/com/djrapitops/plan/gathering/listeners/velocity/PlayerOnlineListener.java @@ -18,8 +18,6 @@ package com.djrapitops.plan.gathering.listeners.velocity; import com.djrapitops.plan.delivery.domain.keys.SessionKeys; import com.djrapitops.plan.delivery.export.Exporter; -import com.djrapitops.plan.delivery.webserver.cache.DataID; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.extension.CallEvents; import com.djrapitops.plan.extension.ExtensionSvc; import com.djrapitops.plan.gathering.cache.SessionCache; @@ -129,10 +127,6 @@ public class PlayerOnlineListener { } UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidateMatching(DataID.SERVER_OVERVIEW); - JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID); - JSONCache.invalidate(DataID.SERVERS); - JSONCache.invalidate(DataID.SESSIONS); } @Subscribe(order = PostOrder.NORMAL) @@ -161,24 +155,6 @@ public class PlayerOnlineListener { if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } - - processing.submit(() -> { - JSONCache.invalidateMatching( - DataID.SERVER_OVERVIEW, - DataID.SESSIONS, - DataID.GRAPH_WORLD_PIE, - DataID.GRAPH_PUNCHCARD, - DataID.KILLS, - DataID.ONLINE_OVERVIEW, - DataID.SESSIONS_OVERVIEW, - DataID.PVP_PVE, - DataID.GRAPH_UNIQUE_NEW, - DataID.GRAPH_CALENDAR - ); - UUID serverUUID = serverInfo.getServerUUID(); - JSONCache.invalidate(DataID.GRAPH_ONLINE, serverUUID); - JSONCache.invalidate(DataID.SERVERS); - }); } @Subscribe(order = PostOrder.LAST) @@ -205,7 +181,5 @@ public class PlayerOnlineListener { if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) { processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName)); } - - JSONCache.invalidate(DataID.SERVERS); } } diff --git a/Plan/velocity/src/main/java/com/djrapitops/plan/modules/velocity/VelocityTaskModule.java b/Plan/velocity/src/main/java/com/djrapitops/plan/modules/velocity/VelocityTaskModule.java index b7efb65f0..1bc5351f9 100644 --- a/Plan/velocity/src/main/java/com/djrapitops/plan/modules/velocity/VelocityTaskModule.java +++ b/Plan/velocity/src/main/java/com/djrapitops/plan/modules/velocity/VelocityTaskModule.java @@ -17,7 +17,6 @@ package com.djrapitops.plan.modules.velocity; import com.djrapitops.plan.TaskSystem; -import com.djrapitops.plan.delivery.webserver.cache.JSONCache; import com.djrapitops.plan.delivery.webserver.cache.JSONFileStorage; import com.djrapitops.plan.extension.ExtensionServerDataUpdater; import com.djrapitops.plan.gathering.timed.ProxyTPSCounter; @@ -57,10 +56,6 @@ public interface VelocityTaskModule { @IntoSet TaskSystem.Task bindDBCleanTask(DBCleanTask cleanTask); - @Binds - @IntoSet - TaskSystem.Task bindJSONCacheCleanTask(JSONCache.CleanTask cleanTask); - @Binds @IntoSet TaskSystem.Task bindRamAndCpuTask(SystemUsageBuffer.RamAndCpuTask ramAndCpuTask);