0

I've introduced redisson lock recently, after that its taking 5-7s for. without lock it takes <1s. (testing locally in both cases). Im I doing anything wrong here. This is local figure, but in production too delay will be proportionally high with lock. Can't afford this huge delay. Fine with few microseconds delay coz of lock.

Redis is cluster mode, 3 masters 3 slaves.

Sample Code:

    public String getDataFromRedis(String key){
       RLock lock = client.getLock(System.nanoTime());

       String data = null;
       try {
           lock.lock(5, TimeUnit.SECONDS);
           data = (String) client.getMapCache("map").get(key);
       } catch (Exception e) {
           LOGGER.error("Exception while getting data from redis, tuple: {}. {}",key, e.getMessage());
       } finally {
           if (lock.isLocked() && lock.isHeldByCurrentThread()) {
               lock.unlock();
               LOGGER.info("Lock unlocked {}",key);
           }
       }
       return data;
    }

Also I couldnt find direct way of inserting/retrieving the data. In all different data structers provided by redisson, we need to get that DataStructure using a keyword & then get actual data. Like in above example I need to get HSet via "map" keyword & then get data Couldn't find any other way. Can someone help with that too?? Coz I want to have both clients redisson & lettuce. In lettuce we can insert/retrieve data directly but not in redisson. So can use both clients interchangebly.

abhijeet104
  • 486
  • 4
  • 9

0 Answers0