mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-25 18:47:50 +01:00
Removed JSONCache and its invalidation uses
This commit is contained in:
parent
f48ab818ef
commit
95af3f5f8b
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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("<pre>### Cached JSON:<br><br>");
|
||||
List<String> cacheKeys = JSONCache.getCachedIDs();
|
||||
if (cacheKeys.isEmpty()) {
|
||||
content.append("Empty");
|
||||
}
|
||||
for (String cacheKey : cacheKeys) {
|
||||
content.append("- ").append(cacheKey).append("<br>");
|
||||
}
|
||||
content.append("</pre>");
|
||||
} 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("<pre>### Session Cache:<br><br>");
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<String, byte[]> cache = Caffeine.newBuilder()
|
||||
.expireAfterAccess(2, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
private JSONCache() {
|
||||
// Static class
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Response getOrCache(String identifier, Supplier<Response> 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<String> 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 <T> Response getOrCache(DataID dataID, Supplier<T> objectSupplier) {
|
||||
return getOrCache(dataID.name(), () -> Response.builder()
|
||||
.setMimeType(MimeType.JSON)
|
||||
.setJSONContent(objectSupplier.get())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static <T> Response getOrCache(DataID dataID, UUID serverUUID, Supplier<T> 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<String> 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<String> getCachedIDs() {
|
||||
List<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
));
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<String> cached = JSONCache.getCachedIDs();
|
||||
assertTrue(cached.contains(TEST_ID.name()));
|
||||
}
|
||||
|
||||
private void assertNotContains() {
|
||||
List<String> 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<String> cached = JSONCache.getCachedIDs();
|
||||
assertTrue(cached.contains(TEST_ID.of(TEST_UUID)));
|
||||
}
|
||||
|
||||
private void assertNotContainsUUID() {
|
||||
List<String> 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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user