9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

make redis thread blocking

This commit is contained in:
XiaoMoMi
2024-07-31 00:31:04 +08:00
parent 35ce90aa65
commit e819f6b079
2 changed files with 1 additions and 2 deletions

View File

@@ -274,6 +274,7 @@ public class BukkitStorageManager implements StorageManager, Listener {
} }
if (triedTimes >= 6) { if (triedTimes >= 6) {
waitLock(uuid, 3); waitLock(uuid, 3);
task.cancel();
return; return;
} }
redisManager.getPlayerData(uuid, false).thenAccept(optionalData -> { redisManager.getPlayerData(uuid, false).thenAccept(optionalData -> {

View File

@@ -265,7 +265,6 @@ public class RedisManager extends AbstractStorage {
@Override @Override
public CompletableFuture<Optional<PlayerData>> getPlayerData(UUID uuid, boolean lock) { public CompletableFuture<Optional<PlayerData>> getPlayerData(UUID uuid, boolean lock) {
var future = new CompletableFuture<Optional<PlayerData>>(); var future = new CompletableFuture<Optional<PlayerData>>();
plugin.getScheduler().async().execute(() -> {
try (Jedis jedis = jedisPool.getResource()) { try (Jedis jedis = jedisPool.getResource()) {
byte[] key = getRedisKey("cf_data", uuid); byte[] key = getRedisKey("cf_data", uuid);
byte[] data = jedis.get(key); byte[] data = jedis.get(key);
@@ -278,7 +277,6 @@ public class RedisManager extends AbstractStorage {
} catch (Exception e) { } catch (Exception e) {
future.complete(Optional.empty()); future.complete(Optional.empty());
} }
});
return future; return future;
} }