Created
February 24, 2020 21:20
-
-
Save brachi-wernick/e9ae1899cee09816dc4b1c1906dfa4cc to your computer and use it in GitHub Desktop.
RedisClient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RedisClient { | |
private static RedissonClient redisClient; | |
public static synchronized void newInstance(){ | |
if(redisClient==null) { | |
Config config = new Config(); | |
config.setCodec(new StringCodec()); | |
config.setThreads(Integer.parseInt(System.getenv("threads"))); | |
config.setNettyThreads(Integer.parseInt(System.getenv("netty"))); | |
config.useClusterServers() | |
.addNodeAddress("redis://<host1>:6379") | |
.addNodeAddress("redis://<host2>:6379"); | |
redisClient = Redisson.create(config); | |
} | |
} | |
public static RedissonClient getRedisClient() { | |
return redisClient; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment