use of com.lcache.extend.handle.redis.jedis.config.JedisClusterConnectSourceConfig in project lcache by long172066912.
the class RedissonClientManager method getJedisRedissonConfig.
/**
* Jedis配置转Redisson配置
*
* @param cacheConfigModel
* @param cacheConfig
* @return
*/
private static Config getJedisRedissonConfig(CacheConfigModel cacheConfigModel, BaseCacheConfig cacheConfig) {
Config config = new Config();
switch(cacheConfigModel.getConnectTypeEnum()) {
case SIMPLE:
JedisConnectSourceConfig simpleConfig = (JedisConnectSourceConfig) cacheConfig;
config.useSingleServer().setAddress("redis://" + simpleConfig.getHost() + ":" + simpleConfig.getPort()).setPassword(StringUtils.isNotBlank(simpleConfig.getPwd()) ? simpleConfig.getPwd() : null);
break;
case POOL:
JedisConnectSourceConfig poolConfig = (JedisConnectSourceConfig) cacheConfig;
config.useSingleServer().setAddress("redis://" + poolConfig.getHost() + ":" + poolConfig.getPort()).setPassword(StringUtils.isNotBlank(poolConfig.getPwd()) ? poolConfig.getPwd() : null);
break;
case SHARDED:
return null;
case CLUSTER:
JedisClusterConnectSourceConfig clusterConfig = (JedisClusterConnectSourceConfig) cacheConfig;
for (HostAndPort hostAndPort : clusterConfig.getNodes()) {
config.useClusterServers().addNodeAddress("redis://" + hostAndPort.getHost() + ":" + hostAndPort.getPort());
}
config.useClusterServers().setScanInterval(2000).setPassword(StringUtils.isNotBlank(clusterConfig.getPwd()) ? clusterConfig.getPwd() : null);
break;
case CLUSTER_POOL:
JedisClusterConnectSourceConfig clusterPoolConfig = (JedisClusterConnectSourceConfig) cacheConfig;
for (HostAndPort hostAndPort : clusterPoolConfig.getNodes()) {
config.useClusterServers().addNodeAddress("redis://" + hostAndPort.getHost() + ":" + hostAndPort.getPort());
}
config.useClusterServers().setScanInterval(2000).setPassword(StringUtils.isNotBlank(clusterPoolConfig.getPwd()) ? clusterPoolConfig.getPwd() : null);
break;
default:
return null;
}
return config;
}
Aggregations