From 2734e20aa978a232c67ac527d85c5f6fe679e6db Mon Sep 17 00:00:00 2001 From: Xharos Date: Wed, 10 Jul 2024 14:19:36 +0200 Subject: [PATCH 1/2] Add cached enum values --- build.gradle.kts | 1 - .../fr/islandswars/commons/service/ServiceType.java | 5 +++++ .../commons/service/rabbitmq/packet/PacketType.java | 6 ++++-- .../commons/service/redis/cache/CacheManager.java | 10 +++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a793d1b..104b069 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,6 @@ dependencies { implementation("io.lettuce:lettuce-core:6.3.2.RELEASE") implementation("com.rabbitmq:amqp-client:5.21.0") implementation("com.github.docker-java:docker-java-core:3.3.6") - implementation("it.unimi.dsi:fastutil:8.2.1") implementation("net.kyori:adventure-api:4.17.0") implementation("com.github.docker-java:docker-java-transport-httpclient5:3.3.6") testImplementation(platform("org.junit:junit-bom:5.9.1")) diff --git a/src/main/java/fr/islandswars/commons/service/ServiceType.java b/src/main/java/fr/islandswars/commons/service/ServiceType.java index bc05e72..436bed3 100644 --- a/src/main/java/fr/islandswars/commons/service/ServiceType.java +++ b/src/main/java/fr/islandswars/commons/service/ServiceType.java @@ -41,6 +41,7 @@ public enum ServiceType { DOCKER_HOST("docker_host"); + private static final ServiceType[] VALUES = values(); private static final String path = "/run/secrets/"; private final String secretFileName; @@ -55,4 +56,8 @@ public String getSecretFileName() { public String getSecretPath() { return path + secretFileName; } + + public static ServiceType[] cachedValues() { + return VALUES; + } } diff --git a/src/main/java/fr/islandswars/commons/service/rabbitmq/packet/PacketType.java b/src/main/java/fr/islandswars/commons/service/rabbitmq/packet/PacketType.java index 9070b3a..dab55d4 100644 --- a/src/main/java/fr/islandswars/commons/service/rabbitmq/packet/PacketType.java +++ b/src/main/java/fr/islandswars/commons/service/rabbitmq/packet/PacketType.java @@ -8,7 +8,9 @@ import fr.islandswars.commons.service.rabbitmq.packet.server.PingRequestPacket; import fr.islandswars.commons.service.rabbitmq.packet.server.StatusRequestPacket; import fr.islandswars.commons.utils.LogUtils; -import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; + +import java.util.HashMap; +import java.util.Map; import static fr.islandswars.commons.service.rabbitmq.packet.PacketType.Bound.*; @@ -38,7 +40,7 @@ */ public class PacketType { - protected static final Int2ObjectArrayMap> packetList = new Int2ObjectArrayMap<>(); + protected static final Map> packetList = new HashMap<>(); private final int id; private final Class packet; diff --git a/src/main/java/fr/islandswars/commons/service/redis/cache/CacheManager.java b/src/main/java/fr/islandswars/commons/service/redis/cache/CacheManager.java index 9655119..4daee8c 100644 --- a/src/main/java/fr/islandswars/commons/service/redis/cache/CacheManager.java +++ b/src/main/java/fr/islandswars/commons/service/redis/cache/CacheManager.java @@ -5,10 +5,10 @@ import fr.islandswars.commons.utils.LogUtils; import fr.islandswars.commons.utils.Preconditions; import io.lettuce.core.api.async.RedisAsyncCommands; -import it.unimi.dsi.fastutil.objects.Object2ObjectMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -40,13 +40,13 @@ public abstract class CacheManager { private final RedisAsyncCommands redis; - private final String keyPrefix; - private final Object2ObjectMap fieldsCache; + private final String keyPrefix; + private final Map fieldsCache; public CacheManager(String keyPrefix, RedisConnection connection) { this.redis = connection.getConnection(); this.keyPrefix = keyPrefix; - this.fieldsCache = new Object2ObjectOpenHashMap<>(); + this.fieldsCache = new HashMap<>(); initializeFieldCache(); updateCache().run(); } From 57000128e153187e003f8879da7bb09505e6cfad Mon Sep 17 00:00:00 2001 From: Xharos Date: Wed, 10 Jul 2024 14:20:21 +0200 Subject: [PATCH 2/2] bump --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 104b069..bdc7fe6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "fr.islandswars" -version = "0.4.2" +version = "0.4.3" repositories { mavenCentral()