mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 02:37:27 +00:00
Added synchronization blocks to functions retrieving objects from CacheHashMaps and made the API use one for caching item stacks as well.
This commit is contained in:
1 parent
3bc02a708e
commit
118d79f3ad
4 files changed
+34
-53
No files matched your search
@@ -4,13 +4,14 @@ 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);
|
||||
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>(10*60*1000);
|
||||
|
||||
public static ImageData getImageData(String directory) {
|
||||
if (!imageDataCache.containsKey(directory)) {
|
||||
ImageData imageData = new ImageData(directory);
|
||||
imageDataCache.put(directory, new CacheHashMap.CachedObject<>(imageData));
|
||||
synchronized (imageDataCache) {
|
||||
if (!imageDataCache.containsKey(directory)) {
|
||||
imageDataCache.put(directory, new CacheHashMap.CachedObject<>(new ImageData(directory)));
|
||||
}
|
||||
return imageDataCache.get(directory).getObject();
|
||||
}
|
||||
return imageDataCache.get(directory).getObject();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user