JSONCache to debug page

This commit is contained in:
Rsl1122 2019-08-31 11:41:02 +03:00
parent f426552b8c
commit 41aa8a1ba0
2 changed files with 27 additions and 5 deletions

View File

@ -23,6 +23,7 @@ import com.djrapitops.plan.delivery.formatting.Formatters;
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;
@ -106,12 +107,13 @@ public class DebugPage implements Page {
private String createCacheContent() {
StringBuilder content = new StringBuilder();
appendResponseCache(content);
appendResourceCache(content);
appendJSONCache(content);
appendSessionCache(content);
return content.toString();
}
private void appendResponseCache(StringBuilder content) {
private void appendResourceCache(StringBuilder content) {
try {
content.append("<pre>### Cached Resources (from File or Jar):<br><br>");
List<String> cacheKeys = ResourceCache.getCachedResourceNames();
@ -127,6 +129,22 @@ 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) {
errorHandler.log(L.WARN, this.getClass(), e);
}
}
private void appendSessionCache(StringBuilder content) {
try {
content.append("<pre>### Session Cache:<br><br>");

View File

@ -22,9 +22,7 @@ import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -109,4 +107,10 @@ public class JSONCache {
public static void cleanUp() {
cache.cleanUp();
}
public static List<String> getCachedIDs() {
List<String> identifiers = new ArrayList<>(cache.asMap().keySet());
Collections.sort(identifiers);
return identifiers;
}
}