mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-24 17:21:21 +01:00
Update Caffeine, use soft values for chunk caches
This commit is contained in:
parent
7cdc8213fa
commit
1b26803527
@ -30,9 +30,9 @@ dependencies {
|
||||
api ("de.bluecolored.bluemap:BlueMapCore")
|
||||
|
||||
compileOnly ("org.jetbrains:annotations:16.0.2")
|
||||
compileOnly ("org.projectlombok:lombok:1.18.30")
|
||||
compileOnly ("org.projectlombok:lombok:1.18.32")
|
||||
|
||||
annotationProcessor ("org.projectlombok:lombok:1.18.30")
|
||||
annotationProcessor ("org.projectlombok:lombok:1.18.32")
|
||||
|
||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
||||
|
@ -60,7 +60,7 @@ repositories {
|
||||
|
||||
@Suppress("GradlePackageUpdate")
|
||||
dependencies {
|
||||
api ("com.github.ben-manes.caffeine:caffeine:2.8.5")
|
||||
api ("com.github.ben-manes.caffeine:caffeine:3.1.8")
|
||||
api ("org.apache.commons:commons-lang3:3.6")
|
||||
api ("commons-io:commons-io:2.5")
|
||||
api ("org.spongepowered:configurate-hocon:4.1.2")
|
||||
@ -73,14 +73,14 @@ dependencies {
|
||||
api ("de.bluecolored.bluemap:BlueMapAPI")
|
||||
|
||||
compileOnly ("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly ("org.projectlombok:lombok:1.18.30")
|
||||
compileOnly ("org.projectlombok:lombok:1.18.32")
|
||||
|
||||
annotationProcessor ("org.projectlombok:lombok:1.18.30")
|
||||
annotationProcessor ("org.projectlombok:lombok:1.18.32")
|
||||
|
||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
||||
testCompileOnly ("org.projectlombok:lombok:1.18.30")
|
||||
testAnnotationProcessor ("org.projectlombok:lombok:1.18.30")
|
||||
testCompileOnly ("org.projectlombok:lombok:1.18.32")
|
||||
testAnnotationProcessor ("org.projectlombok:lombok:1.18.32")
|
||||
}
|
||||
|
||||
spotless {
|
||||
|
@ -25,14 +25,16 @@
|
||||
package de.bluecolored.bluemap.core.map.lowres;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.github.benmanes.caffeine.cache.*;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.RemovalCause;
|
||||
import com.github.benmanes.caffeine.cache.Scheduler;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.storage.GridStorage;
|
||||
import de.bluecolored.bluemap.core.util.Grid;
|
||||
import de.bluecolored.bluemap.core.util.Vector2iCache;
|
||||
import de.bluecolored.bluemap.core.util.math.Color;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -77,15 +79,7 @@ public LowresLayer(
|
||||
.scheduler(Scheduler.systemScheduler())
|
||||
.expireAfterAccess(10, TimeUnit.SECONDS)
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.writer(new CacheWriter<Vector2i, LowresTile>() {
|
||||
@Override
|
||||
public void write(@NonNull Vector2i key, @NonNull LowresTile value) {}
|
||||
|
||||
@Override
|
||||
public void delete(@NonNull Vector2i key, @Nullable LowresTile value, @NonNull RemovalCause cause) {
|
||||
saveTile(key, value);
|
||||
}
|
||||
})
|
||||
.removalListener((Vector2i key, LowresTile value, RemovalCause cause) -> saveTile(key, value))
|
||||
.build(tileWeakInstanceCache::get);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,10 @@
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@ -76,13 +79,17 @@ public class MCAWorld implements World {
|
||||
private final ChunkLoader chunkLoader = new ChunkLoader(this);
|
||||
private final LoadingCache<Vector2i, Region> regionCache = Caffeine.newBuilder()
|
||||
.executor(BlueMap.THREAD_POOL)
|
||||
.softValues()
|
||||
.maximumSize(32)
|
||||
.expireAfterWrite(10, TimeUnit.MINUTES)
|
||||
.expireAfterAccess(1, TimeUnit.MINUTES)
|
||||
.build(this::loadRegion);
|
||||
private final LoadingCache<Vector2i, Chunk> chunkCache = Caffeine.newBuilder()
|
||||
.executor(BlueMap.THREAD_POOL)
|
||||
.softValues()
|
||||
.maximumSize(10240) // 10 regions worth of chunks
|
||||
.expireAfterWrite(10, TimeUnit.MINUTES)
|
||||
.expireAfterAccess(1, TimeUnit.MINUTES)
|
||||
.build(this::loadChunk);
|
||||
|
||||
private MCAWorld(Path worldFolder, Key dimension, DataPack dataPack, LevelData levelData) {
|
||||
|
Loading…
Reference in New Issue
Block a user