CacheHashMap:

-New class extending from the HashMap class, only takes CacheHashMap.CachedObject as values, which itself is a template class.
-On every call to get(), it goes through its values and removes any that are past a set age in millis.

ClientCache:
-New class with static CacheHashMap and function to get image data, will do more caching later on.
This commit is contained in:
Luis C.M committed 2023-05-30 23:41:37 -05:00
1 parent ab8e966f71
commit 46febe5c0a
6 files changed
+83 -17

No files matched your search

@@ -21,7 +21,6 @@ public class Client {
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
private static HashMap<String, ImageData> imageDataCache = new HashMap<>();
public static void sendData(final EnumPacketServer enu, final Object... obs) {
ByteBuf buffer = Unpooled.buffer();
@@ -33,12 +32,4 @@ public class Client {
e.printStackTrace();
}
}
public static ImageData getImageData(String directory) {
if (!imageDataCache.containsKey(directory)) {
ImageData downloadData = new ImageData(directory);
imageDataCache.put(directory, downloadData);
}
return imageDataCache.get(directory);
}
}