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