Files
CustomNPC-Plus/src/main/java/noppes/npcs/client/ClientCache.java
T
Luis C.M 46febe5c0a 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.
2023-05-30 23:41:37 -05:00

17 lines
621 B
Java

package noppes.npcs.client;
import noppes.npcs.client.renderer.customitem.ImageData;
import noppes.npcs.util.CacheHashMap;
public class ClientCache {
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>(10*1000);
public static ImageData getImageData(String directory) {
if (!imageDataCache.containsKey(directory)) {
ImageData imageData = new ImageData(directory);
imageDataCache.put(directory, new CacheHashMap.CachedObject<>(imageData));
}
return imageDataCache.get(directory).getObject();
}
}