Java Code Examples for io.lettuce.core.RedisURI#Builder
The following examples show how to use
io.lettuce.core.RedisURI#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisDataSource.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
private RedisClient getRedisStandaloneClient(RedisConnectionConfig connectionConfig) { char[] password = connectionConfig.getPassword(); String clientName = connectionConfig.getClientName(); RedisURI.Builder redisUriBuilder = RedisURI.builder(); redisUriBuilder.withHost(connectionConfig.getHost()) .withPort(connectionConfig.getPort()) .withDatabase(connectionConfig.getDatabase()) .withTimeout(Duration.ofMillis(connectionConfig.getTimeout())); if (password != null) { redisUriBuilder.withPassword(connectionConfig.getPassword()); } if (StringUtil.isNotEmpty(connectionConfig.getClientName())) { redisUriBuilder.withClientName(clientName); } return RedisClient.create(redisUriBuilder.build()); }
Example 2
Source File: RedisDataSource.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
private RedisClient getRedisSentinelClient(RedisConnectionConfig connectionConfig) { char[] password = connectionConfig.getPassword(); String clientName = connectionConfig.getClientName(); RedisURI.Builder sentinelRedisUriBuilder = RedisURI.builder(); for (RedisConnectionConfig config : connectionConfig.getRedisSentinels()) { sentinelRedisUriBuilder.withSentinel(config.getHost(), config.getPort()); } if (password != null) { sentinelRedisUriBuilder.withPassword(connectionConfig.getPassword()); } if (StringUtil.isNotEmpty(connectionConfig.getClientName())) { sentinelRedisUriBuilder.withClientName(clientName); } sentinelRedisUriBuilder.withSentinelMasterId(connectionConfig.getRedisSentinelMasterId()) .withTimeout(connectionConfig.getTimeout(), TimeUnit.MILLISECONDS); return RedisClient.create(sentinelRedisUriBuilder.build()); }
Example 3
Source File: Client.java From sherlock with GNU General Public License v3.0 | 6 votes |
/** * @param hostname Redis hostname * @param port Redis port * @param ssl whether to use SSL * @param password Redis password * @param timeout Redis timeout * @return a Redis URI used to create clients */ protected static RedisURI produceURI( String hostname, String port, String ssl, String password, String timeout ) { validateHostname(hostname); RedisURI.Builder builder = RedisURI.Builder .redis(hostname, getPortNumber(port)) .withSsl(getSSL(ssl)) .withTimeout(getTimeout(timeout), TimeUnit.MILLISECONDS); if (null != password && !password.isEmpty()) { builder.withPassword(password); } return builder.build(); }
Example 4
Source File: RedisDataSource.java From Sentinel with Apache License 2.0 | 6 votes |
private RedisClient getRedisStandaloneClient(RedisConnectionConfig connectionConfig) { char[] password = connectionConfig.getPassword(); String clientName = connectionConfig.getClientName(); RedisURI.Builder redisUriBuilder = RedisURI.builder(); redisUriBuilder.withHost(connectionConfig.getHost()) .withPort(connectionConfig.getPort()) .withDatabase(connectionConfig.getDatabase()) .withTimeout(Duration.ofMillis(connectionConfig.getTimeout())); if (password != null) { redisUriBuilder.withPassword(connectionConfig.getPassword()); } if (StringUtil.isNotEmpty(connectionConfig.getClientName())) { redisUriBuilder.withClientName(clientName); } return RedisClient.create(redisUriBuilder.build()); }
Example 5
Source File: RedisDataSource.java From Sentinel with Apache License 2.0 | 6 votes |
private RedisClient getRedisSentinelClient(RedisConnectionConfig connectionConfig) { char[] password = connectionConfig.getPassword(); String clientName = connectionConfig.getClientName(); RedisURI.Builder sentinelRedisUriBuilder = RedisURI.builder(); for (RedisConnectionConfig config : connectionConfig.getRedisSentinels()) { sentinelRedisUriBuilder.withSentinel(config.getHost(), config.getPort()); } if (password != null) { sentinelRedisUriBuilder.withPassword(connectionConfig.getPassword()); } if (StringUtil.isNotEmpty(connectionConfig.getClientName())) { sentinelRedisUriBuilder.withClientName(clientName); } sentinelRedisUriBuilder.withSentinelMasterId(connectionConfig.getRedisSentinelMasterId()) .withTimeout(connectionConfig.getTimeout(), TimeUnit.MILLISECONDS); return RedisClient.create(sentinelRedisUriBuilder.build()); }
Example 6
Source File: RedisRateLimiterConfiguration.java From daming with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(value = RequestRateLimiterFactory.class) public RedisRateLimiterFactory redisRateLimiterFactory(ClientResources redisClientResources, RedisProperties redisProperties) { RedisURI.Builder builder = RedisURI.builder() .withHost(redisProperties.getHost()) .withPort(redisProperties.getPort()); if (!StringUtils.isEmpty(redisProperties.getPassword())) { builder = builder.withPassword(redisProperties.getPassword()); } if (null != redisProperties.getTimeout()) { builder = builder.withTimeout(redisProperties.getTimeout()); } builder = builder.withDatabase(redisProperties.getDatabase()) .withSsl(redisProperties.isSsl()); RedisURI redisUri = builder.build(); return new RedisRateLimiterFactory(RedisClient.create(redisClientResources, redisUri)); }
Example 7
Source File: RedisConnectorConfig.java From kafka-connect-redis with Apache License 2.0 | 6 votes |
public List<RedisURI> redisURIs() { List<RedisURI> result = new ArrayList<>(); for (HostAndPort host : this.hosts) { RedisURI.Builder builder = RedisURI.builder(); builder.withHost(host.getHost()); builder.withPort(host.getPort()); builder.withDatabase(this.database); if (!Strings.isNullOrEmpty(this.password)) { builder.withPassword(this.password); } builder.withSsl(this.sslEnabled); result.add(builder.build()); } return result; }