redis tests - hashes

master
Alex 2022-03-26 19:26:39 +01:00
parent 46e03ec877
commit e56d822bde
3 changed files with 23 additions and 1 deletions

View File

@ -116,6 +116,9 @@ public class PostLoginListener implements Listener {
.set("player:" + proxiedPlayer.getUniqueId().toString(), .set("player:" + proxiedPlayer.getUniqueId().toString(),
packer.toByteArray()); packer.toByteArray());
ProxySystem.getInstance().getRedisManager().getRedisHashCommands()
.hset("player", proxiedPlayer.getUniqueId().toString(), "online");
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(packer.toByteArray()); MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(packer.toByteArray());
String playerName = unpacker.unpackString(); String playerName = unpacker.unpackString();

View File

@ -0,0 +1,18 @@
package net.krakatoa.proxy.redis;
import io.lettuce.core.Value;
import io.lettuce.core.dynamic.Commands;
import io.lettuce.core.dynamic.annotation.Key;
import java.util.Map;
import reactor.core.publisher.Mono;
public interface RedisHashCommands extends Commands {
Mono<Long> hdel(Key key, Key... fields);
Mono<Boolean> hset(Key key, Key field, Value value);
Boolean hset(String key, String field, String value);
Mono<String> hmset(Key key, Map<Key, Value> map);
}

View File

@ -15,12 +15,13 @@ public class RedisManager {
//private RedisKeyReactiveCommands<String, String> keyReactiveCommands; //private RedisKeyReactiveCommands<String, String> keyReactiveCommands;
private RedisKeyCommands redisKeyCommands; private RedisKeyCommands redisKeyCommands;
private RedisHashCommands redisHashCommands;
public void connect() { public void connect() {
this.client = RedisClient.create(this.getConnectionUri()); this.client = RedisClient.create(this.getConnectionUri());
RedisCommandFactory factory = new RedisCommandFactory(client.connect()); RedisCommandFactory factory = new RedisCommandFactory(client.connect());
this.redisKeyCommands = factory.getCommands(RedisKeyCommands.class); this.redisKeyCommands = factory.getCommands(RedisKeyCommands.class);
this.redisHashCommands = factory.getCommands(RedisHashCommands.class);
//this.connection = client.connect(); //this.connection = client.connect();
//this.commands = connection.sync(); //this.commands = connection.sync();
//this.keyReactiveCommands = this.connection.reactive(); //this.keyReactiveCommands = this.connection.reactive();