implement redis command interface
parent
dc9232c420
commit
6ea1aef3a7
|
@ -12,10 +12,10 @@ public class PlayerDisconnectListener implements Listener {
|
|||
public void onDisconnect(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer proxiedPlayer = event.getPlayer();
|
||||
|
||||
String value = ProxySystem.getInstance().getRedisManager().getCommands()
|
||||
.getdel("player:" + proxiedPlayer.getUniqueId().toString());
|
||||
Long res = ProxySystem.getInstance().getRedisManager().getRedisKeyCommands()
|
||||
.del("player:" + proxiedPlayer.getUniqueId().toString());
|
||||
|
||||
ProxySystem.getInstance().getLogger().info("val: " + value);
|
||||
ProxySystem.getInstance().getLogger().info("val: " + res);
|
||||
|
||||
//String uuid = ProxySystem.getInstance().getFormatter()
|
||||
// .formatUuid(proxiedPlayer.getUniqueId().toString());
|
||||
|
|
|
@ -98,7 +98,7 @@ public class PostLoginListener implements Listener {
|
|||
}
|
||||
});
|
||||
|
||||
ProxySystem.getInstance().getRedisManager().getCommands()
|
||||
ProxySystem.getInstance().getRedisManager().getRedisKeyCommands()
|
||||
.set("player:" + proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import io.lettuce.core.dynamic.Commands;
|
||||
import io.lettuce.core.dynamic.annotation.Key;
|
||||
|
||||
public interface RedisKeyCommands extends Commands {
|
||||
|
||||
String get(String key);
|
||||
|
||||
String set(String key, String value);
|
||||
|
||||
Long del(Key... keys);
|
||||
|
||||
Long del(String key);
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package net.krakatoa.proxy.redis;
|
||||
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.api.StatefulRedisConnection;
|
||||
import io.lettuce.core.api.sync.RedisStringCommands;
|
||||
import io.lettuce.core.dynamic.RedisCommandFactory;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
@ -11,14 +10,19 @@ public class RedisManager {
|
|||
private final String connectionUri;
|
||||
|
||||
private RedisClient client;
|
||||
private StatefulRedisConnection<String, String> connection;
|
||||
private RedisStringCommands<String, String> commands;
|
||||
//private StatefulRedisConnection<String, String> connection;
|
||||
//private RedisStringCommands<String, String> commands;
|
||||
//private RedisKeyReactiveCommands<String, String> keyReactiveCommands;
|
||||
|
||||
private RedisKeyCommands redisKeyCommands;
|
||||
|
||||
public void connect() {
|
||||
this.client = RedisClient.create(this.getConnectionUri());
|
||||
this.connection = client.connect();
|
||||
this.commands = connection.sync();
|
||||
RedisCommandFactory factory = new RedisCommandFactory(client.connect());
|
||||
this.redisKeyCommands = factory.getCommands(RedisKeyCommands.class);
|
||||
|
||||
//this.connection = client.connect();
|
||||
//this.commands = connection.sync();
|
||||
//this.keyReactiveCommands = this.connection.reactive();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue