mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-28 02:54:20 +01:00
Deprecate JSONCache
This commit is contained in:
parent
b660c3b57b
commit
ab5e0120be
@ -40,6 +40,7 @@ import java.util.stream.Collectors;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class JSONCache {
|
public class JSONCache {
|
||||||
|
|
||||||
private static final Cache<String, byte[]> cache = Caffeine.newBuilder()
|
private static final Cache<String, byte[]> cache = Caffeine.newBuilder()
|
||||||
@ -50,6 +51,7 @@ public class JSONCache {
|
|||||||
// Static class
|
// Static class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static Response getOrCache(String identifier, Supplier<Response> jsonResponseSupplier) {
|
public static Response getOrCache(String identifier, Supplier<Response> jsonResponseSupplier) {
|
||||||
byte[] found = cache.getIfPresent(identifier);
|
byte[] found = cache.getIfPresent(identifier);
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
@ -63,6 +65,7 @@ public class JSONCache {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String getOrCacheString(DataID dataID, UUID serverUUID, Supplier<String> stringSupplier) {
|
public static String getOrCacheString(DataID dataID, UUID serverUUID, Supplier<String> stringSupplier) {
|
||||||
String identifier = dataID.of(serverUUID);
|
String identifier = dataID.of(serverUUID);
|
||||||
byte[] found = cache.getIfPresent(identifier);
|
byte[] found = cache.getIfPresent(identifier);
|
||||||
@ -74,6 +77,7 @@ public class JSONCache {
|
|||||||
return new String(found, StandardCharsets.UTF_8);
|
return new String(found, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static <T> Response getOrCache(DataID dataID, Supplier<T> objectSupplier) {
|
public static <T> Response getOrCache(DataID dataID, Supplier<T> objectSupplier) {
|
||||||
return getOrCache(dataID.name(), () -> Response.builder()
|
return getOrCache(dataID.name(), () -> Response.builder()
|
||||||
.setMimeType(MimeType.JSON)
|
.setMimeType(MimeType.JSON)
|
||||||
@ -81,6 +85,7 @@ public class JSONCache {
|
|||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static <T> Response getOrCache(DataID dataID, UUID serverUUID, Supplier<T> objectSupplier) {
|
public static <T> Response getOrCache(DataID dataID, UUID serverUUID, Supplier<T> objectSupplier) {
|
||||||
return getOrCache(dataID.of(serverUUID), () -> Response.builder()
|
return getOrCache(dataID.of(serverUUID), () -> Response.builder()
|
||||||
.setMimeType(MimeType.JSON)
|
.setMimeType(MimeType.JSON)
|
||||||
@ -88,24 +93,29 @@ public class JSONCache {
|
|||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidate(String identifier) {
|
public static void invalidate(String identifier) {
|
||||||
cache.invalidate(identifier);
|
cache.invalidate(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidate(DataID dataID) {
|
public static void invalidate(DataID dataID) {
|
||||||
invalidate(dataID.name());
|
invalidate(dataID.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidate(UUID serverUUID, DataID... dataIDs) {
|
public static void invalidate(UUID serverUUID, DataID... dataIDs) {
|
||||||
for (DataID dataID : dataIDs) {
|
for (DataID dataID : dataIDs) {
|
||||||
invalidate(dataID.of(serverUUID));
|
invalidate(dataID.of(serverUUID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidate(DataID dataID, UUID serverUUID) {
|
public static void invalidate(DataID dataID, UUID serverUUID) {
|
||||||
invalidate(dataID.of(serverUUID));
|
invalidate(dataID.of(serverUUID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidateMatching(DataID... dataIDs) {
|
public static void invalidateMatching(DataID... dataIDs) {
|
||||||
Set<String> toInvalidate = Arrays.stream(dataIDs)
|
Set<String> toInvalidate = Arrays.stream(dataIDs)
|
||||||
.map(DataID::name)
|
.map(DataID::name)
|
||||||
@ -119,6 +129,7 @@ public class JSONCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidateMatching(DataID dataID) {
|
public static void invalidateMatching(DataID dataID) {
|
||||||
String toInvalidate = dataID.name();
|
String toInvalidate = dataID.name();
|
||||||
for (String identifier : cache.asMap().keySet()) {
|
for (String identifier : cache.asMap().keySet()) {
|
||||||
@ -128,14 +139,17 @@ public class JSONCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void invalidateAll() {
|
public static void invalidateAll() {
|
||||||
cache.invalidateAll();
|
cache.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void cleanUp() {
|
public static void cleanUp() {
|
||||||
cache.cleanUp();
|
cache.cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static List<String> getCachedIDs() {
|
public static List<String> getCachedIDs() {
|
||||||
List<String> identifiers = new ArrayList<>(cache.asMap().keySet());
|
List<String> identifiers = new ArrayList<>(cache.asMap().keySet());
|
||||||
Collections.sort(identifiers);
|
Collections.sort(identifiers);
|
||||||
|
Loading…
Reference in New Issue
Block a user