This commit is contained in:
YuTian 2024-07-22 15:47:21 +08:00
parent 16794f85fb
commit 99060abcbb
3 changed files with 57 additions and 13 deletions

View File

@ -1,7 +1,7 @@
package com.io.yutian.aulib.redis;
import com.io.yutian.aulib.AuLib;
import it.unimi.dsi.fastutil.Pair;
import com.io.yutian.aulib.util.Pair;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@ -44,19 +44,21 @@ public class RedisCacheSyncTimer {
RedisCacheSynchronizer synchronizer = entry1.getValue();
String k1 = key.first();
String k2 = key.second();
for (String k : jedis.keys(k1+":*")) {
String data = null;
if (k2 == null) {
data = jedis.get(k1);
data = jedis.get(k);
} else {
data = jedis.hget(k1, k2);
data = jedis.hget(k, k2);
}
if (data != null) {
String finalData = data;
synchronizer.sync(finalData);
if (k2 == null) {
jedis.del(k1);
jedis.del(k);
} else {
jedis.hdel(k1, k2);
jedis.hdel(k, k2);
}
}
}
}

View File

@ -0,0 +1,42 @@
package com.io.yutian.aulib.util;
public class Pair<L, R> {
protected final L left;
protected final R right;
public Pair(L left, R right) {
this.left = left;
this.right = right;
}
public static <K, V> Pair<K, V> of(K left, V right) {
return new Pair(left, right);
}
public L left() {
return this.left;
}
public R right() {
return this.right;
}
public L first() {
return this.left();
}
public R second() {
return this.right();
}
public L key() {
return this.left();
}
public R value() {
return this.right();
}
}

View File

@ -1,5 +1,5 @@
name: AuLib
main: com.io.yutian.aulib.AuLib
version: 2.3
version: 2.4
api-version: 1.18
author: SuperYuTian