replace dumb caches with guava caches

This commit is contained in:
dfsek
2021-01-14 00:34:23 -07:00
parent 8fd3530653
commit cbc2885c16
7 changed files with 81 additions and 113 deletions
@@ -1,25 +0,0 @@
package com.dfsek.terra.biome;
import com.dfsek.terra.api.math.vector.Vector2;
import com.dfsek.terra.biome.pipeline.BiomeHolder;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.jetbrains.annotations.NotNull;
public class BiomeCache {
LoadingCache<Vector2, BiomeHolder> cache;
public BiomeCache() {
cache = CacheBuilder.newBuilder()
.maximumSize(1024)
.build(
new CacheLoader<Vector2, BiomeHolder>() {
@Override
public BiomeHolder load(@NotNull Vector2 key) throws Exception {
return null;
}
}
);
}
}
@@ -50,11 +50,7 @@ public class StandardBiomeProvider implements BiomeProvider {
@Override
public TerraBiome getBiome(int x, int z) {
try {
return biomeCache.get(new Vector2(x, z));
} catch(ExecutionException e) {
throw new RuntimeException(e);
}
return biomeCache.getUnchecked(new Vector2(x, z));
}
public int getResolution() {