Reputation: 415
I am currently testing reddison client for redis. For a simple RMap set and get I am getting a time of 10ms. When comparing it to jedis, jedis only takes 2 ms to complete set and get. My reddison test code is below
public static void main(String[] args) {
Config config = new Config();
config.useSentinelServers().setCheckSentinelsList(false).setMasterName("mymaster")
.addSentinelAddress("redis://localhost:26379").setPassword("zzz");
RedissonClient redisson = Redisson.create(config);
RMap<String, String> map = redisson.getMap("myMap");
while (true) {
System.out.println("ENTER");
Scanner in = new Scanner(System.in);
String s = in.nextLine();
try {
LocalDateTime start = LocalDateTime.now();
map.put("test", s);
System.out.println("OUTPUT:::" + map.get("test"));
System.out.println(Duration.between(start, LocalDateTime.now()).toMillis());
} catch (Exception e) {
e.printStackTrace();
}
}
}
After checking debug logs I found out that reddison acquires a connection every time before doing a put or get( LOG:: acquired connection for command ). Is there a way to keep redisson client use the same connection for all requests and avoid this cost?
Upvotes: 1
Views: 1682
Reputation: 10793
Redisson uses connection pool. Never creates new connection per operation. First operation with data may require default codec to do initialization. Since 3.16.1 version default data codec warmup process has been added.
Upvotes: 1