So, I have a value type :
class Session {
long createdAt;
List<String> postIds;
}
Using the jedis client(3.0.0-m1
is that matters), I am currently performing an hset
to create the entries and hgetAll
to retrieve all the key-values:
private redis.clients.jedis.Jedis jedis;
void createSession(String idAsKey, Map<String, String> hashFieldValues) {
jedis.hset(idAsKey, hashFieldValues);
}
Map<String, String> fetchSession(String idAsKey) {
return jedis.hgetAll(idAsKey);
}
The challenge that I am currently looking at is the ease of converting the Map<String, String>
into the Session
object. Is there an existing way to do this?
Server response for an equivalent command
1) "createdAt" 2) "1556099708307" 3) "postIds" 4) "[a, b, c]"
PS: Starting to learn Redis, hoping this kind of mapping might have already been solved for. Yes, not looking for a client change as an answer at least.