How to save this data into Redis by using Jedis library?

1.1k Views Asked by At

I am new in redis database and I need a bit help. I need to store lot of values to speciefied key, I'm making a punishment system for Minecraft so I need to store Player, PlayerUUID, Staff, Reason, Time, Date, Active, Unbanned by, Unban reason, Unban Date. There are 4 types of punishments(each will have separate table): Bans, Mutes, Warnings, Blacklists.

1

There are 1 best solutions below

0
On

One alternative for storing the data in Redis is to use the Hash datatype to store your data. Using code like:

try {Jedis jedis = pool.getResource()) {
    Map<String,String> map = new HashMap<String,String>();
    map.set("Reason", "Some Reason!");
    ...
    jedis.hmset("player:" + playerUUID + ":", map);
}

Assuming the player's UUID is the best primary identifier. You will likely need to add additional mappings for other lookup keys to the UUID or whatever primary identifier you choose.