0

I have used Redission client libraries to create an RMap. When I am fetching the data Redis does 2 commands to fetch the data which is what I want to reduce.

Here is my Sample Code:

RMap<String, Map<String, List<String>>> map = redisClient.getMap("mycache");
String result = Optional.ofNullable(map).map(aMap -> aMap.get(key1)).map(aMap-> aMap.get(key2));

When running this code in debug, I see that for each get(), redission client is fetching from the redis server.

Is there a way I can reduce the call to just one? In fact, I have a 4 level map object in cache and 4 calls to the redis server is taking roughly around 200 ms which is what I want to improve. Any suggestion is welcome. FYI, I am using Open Source redission client not the PRO version.

Simon Kraemer
  • 5,700
  • 1
  • 19
  • 49
  • Did you try to use single Map with composite key, like key1 + key2 ? – Nikita Koksharov Mar 20 '19 at 07:29
  • 1
    Thank you @NikitaKoksharov . I have now changed the Data Structure not to contain Map<> rather use an RMap reference. That way I do not have to do nested get() rather, create use a composite key to fetch the required data. – Pravat Kumar Sahoo Mar 21 '19 at 09:13

0 Answers0