public @Bean RedisConnectionFactory connectionFactory() { return new LettuceConnectionFactory(sentinelConfig(), LettuceClientConfiguration.defaultConfiguration()); }
@Test @SuppressWarnings("unused") public void newReactiveRedisOperationsSessionRepository() { LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(); RedisSerializationContext<String, Object> serializationContext = RedisSerializationContext .<String, Object>newSerializationContext( new JdkSerializationRedisSerializer()) .build(); // tag::new-reactiveredisoperationssessionrepository[] // ... create and configure connectionFactory and serializationContext ... ReactiveRedisTemplate<String, Object> redisTemplate = new ReactiveRedisTemplate<>( connectionFactory, serializationContext); ReactiveSessionRepository<? extends Session> repository = new ReactiveRedisOperationsSessionRepository(redisTemplate); // end::new-reactiveredisoperationssessionrepository[] }
@Bean public LettuceConnectionFactory connectionFactory() { return new LettuceConnectionFactory(host,port); } }
@Bean public LettuceConnectionFactory redisConnectionFactory() { return new LettuceConnectionFactory(); }
@Bean public ReactiveRedisConnectionFactory connectionFactory() { return new LettuceConnectionFactory("localhost", 6379); }
@Bean public ReactiveRedisConnectionFactory connectionFactory() { return new LettuceConnectionFactory("localhost", 6379); }
protected static void setupConnectionFactory() { RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); redisStandaloneConfiguration.setPort(REDIS_PORT); LettuceClientConfiguration clientConfiguration = LettuceClientConfiguration.builder() .clientOptions( ClientOptions.builder() .socketOptions( SocketOptions.builder() .connectTimeout(Duration.ofMillis(10000)) .build()) .build()) .commandTimeout(Duration.ofSeconds(10000)) .build(); connectionFactory = new LettuceConnectionFactory(redisStandaloneConfiguration, clientConfiguration); connectionFactory.afterPropertiesSet(); }
@Bean public LettuceConnectionFactory redisConnectionFactory() { RedisStandaloneConfiguration redisConf = new RedisStandaloneConfiguration(); redisConf.setHostName(env.getProperty("spring.redis.host")); redisConf.setPort(Integer.parseInt(env.getProperty("spring.redis.port"))); redisConf.setPassword(RedisPassword.of(env.getProperty("spring.redis.password"))); return new LettuceConnectionFactory(redisConf); }
@Override protected void obtainResource() throws Exception { resource = new LettuceConnectionFactory(); resource.afterPropertiesSet(); resource.getConnection().close(); } }
@Override protected RedisConnectionFactory createConnectionClient(String hostName, int port) { RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(); configuration.setHostName(hostName); configuration.setPort(port); if (JEDIS_AVAILABLE) { return new JedisConnectionFactory(configuration); } else if (LETTUCE_AVAILABLE) { return new LettuceConnectionFactory(configuration); } else { throw new IllegalArgumentException("No Jedis or lettuce client on classpath. " + "Please add one of the implementation to your classpath"); } } }
@Override protected RedisConnectionFactory createConnectionClient(String hostName, int port) { RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(); configuration.setHostName(hostName); configuration.setPort(port); if (JEDIS_AVAILABLE) { return new JedisConnectionFactory(configuration); } else if (LETTUCE_AVAILABLE) { return new LettuceConnectionFactory(configuration); } else { throw new IllegalArgumentException("No Jedis or lettuce client on classpath. " + "Please add one of the implementation to your classpath"); } } }
@Bean public LettuceConnectionFactory lettuceConnectionFactory() throws Exception { LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(); connectionFactory.setHostName( (String) redisHost().getObject() ); connectionFactory.setPassword( (String) redisPassword().getObject() ); connectionFactory.setPort( Integer.parseInt( (String) redisPort().getObject() ) ); connectionFactory.setUseSsl( Boolean.parseBoolean( (String) redisSslEnabled().getObject() ) ); return connectionFactory; }
configuration.setMaxRedirects(propertiesUtil.getInt("redis.cluster.max-redirects")); configuration.setPassword(password); connectionFactory = new LettuceConnectionFactory(configuration, clientConfiguration); } else if (StringUtils.isNotEmpty(master) && StringUtils.isNotEmpty(sentinels)) { Set<String> set = ArrayUtils.newHashSet(sentinels.split(",")); RedisSentinelConfiguration configuration = new RedisSentinelConfiguration(master, set); configuration.setPassword(password); connectionFactory = new LettuceConnectionFactory(configuration, clientConfiguration); } else { RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(); configuration.setHostName(host); configuration.setPort(port); connectionFactory = new LettuceConnectionFactory(configuration, clientConfiguration);
? new LettuceConnectionFactory(sentinelConfiguration, poolConfig) : new LettuceConnectionFactory(standaloneConfig);
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(); connectionFactory.setHostName(serviceInfo.getHost()); connectionFactory.setPort(serviceInfo.getPort());
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(); connectionFactory.setHostName(serviceInfo.getHost()); connectionFactory.setPort(serviceInfo.getPort());
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(); connectionFactory.setHostName(serviceInfo.getHost()); connectionFactory.setPort(serviceInfo.getPort());
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(configuration, builder.build()); connectionFactory.afterPropertiesSet(); return connectionFactory;
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(configuration, builder.build()); connectionFactory.afterPropertiesSet(); return connectionFactory;
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(configuration, builder.build()); connectionFactory.afterPropertiesSet(); return connectionFactory;