Search in sources :

Example 1 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project pivotal-cla by pivotalsoftware.

the class SessionConfig method cloudRedisConnectionFactory.

@Profile(GitHubClaProfiles.CLOUDFOUNDRY)
@Bean
public RedisConnectionFactory cloudRedisConnectionFactory() {
    CloudFactory cloudFactory = new CloudFactory();
    Cloud cloud = cloudFactory.getCloud();
    RedisConnectionFactory connectionFactory = cloud.getSingletonServiceConnector(RedisConnectionFactory.class, null);
    if (connectionFactory instanceof LettuceConnectionFactory) {
        ((LettuceConnectionFactory) connectionFactory).setShutdownTimeout(0);
    }
    return connectionFactory;
}
Also used : CloudFactory(org.springframework.cloud.CloudFactory) Cloud(org.springframework.cloud.Cloud) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) Profile(org.springframework.context.annotation.Profile) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-session by spring-projects.

the class IndexDocTests method newReactiveRedisOperationsSessionRepository.

@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[]
}
Also used : ReactiveRedisTemplate(org.springframework.data.redis.core.ReactiveRedisTemplate) JdkSerializationRedisSerializer(org.springframework.data.redis.serializer.JdkSerializationRedisSerializer) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) ReactiveRedisOperationsSessionRepository(org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository) Test(org.junit.Test)

Example 3 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class RedisServiceConnectorCreatorTest method assertConnectorProperties.

private void assertConnectorProperties(RedisServiceInfo serviceInfo, RedisConnectionFactory connector, boolean isSecure) {
    assertNotNull(connector);
    if (connector instanceof JedisConnectionFactory) {
        JedisConnectionFactory connectionFactory = (JedisConnectionFactory) connector;
        assertEquals(serviceInfo.getHost(), connectionFactory.getHostName());
        assertEquals(serviceInfo.getPort(), connectionFactory.getPort());
        assertEquals(serviceInfo.getPassword(), connectionFactory.getPassword());
        assertEquals(isSecure, connectionFactory.isUseSsl());
    } else if (connector instanceof LettuceConnectionFactory) {
        LettuceConnectionFactory connectionFactory = (LettuceConnectionFactory) connector;
        assertEquals(serviceInfo.getHost(), connectionFactory.getHostName());
        assertEquals(serviceInfo.getPort(), connectionFactory.getPort());
        assertEquals(serviceInfo.getPassword(), connectionFactory.getPassword());
        assertEquals(isSecure, connectionFactory.isUseSsl());
    } else {
        fail("Expected RedisConnectionFactory of type " + JedisConnectionFactory.class.getName() + " or " + LettuceConnectionFactory.class.getName() + " but was of type " + connector.getClass().getName());
    }
}
Also used : JedisConnectionFactory(org.springframework.data.redis.connection.jedis.JedisConnectionFactory) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)

Example 4 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-cloud-connectors by spring-cloud.

the class SpringData1RedisServiceConnectorCreatorTest method assertConnectorProperties.

private void assertConnectorProperties(RedisServiceInfo serviceInfo, RedisConnectionFactory connector) {
    assertNotNull(connector);
    if (connector instanceof JedisConnectionFactory) {
        JedisConnectionFactory connectionFactory = (JedisConnectionFactory) connector;
        assertEquals(serviceInfo.getHost(), connectionFactory.getHostName());
        assertEquals(serviceInfo.getPort(), connectionFactory.getPort());
        assertEquals(serviceInfo.getPassword(), connectionFactory.getPassword());
    } else if (connector instanceof LettuceConnectionFactory) {
        LettuceConnectionFactory connectionFactory = (LettuceConnectionFactory) connector;
        assertEquals(serviceInfo.getHost(), connectionFactory.getHostName());
        assertEquals(serviceInfo.getPort(), connectionFactory.getPort());
        assertEquals(serviceInfo.getPassword(), connectionFactory.getPassword());
    } else {
        fail("Expected RedisConnectionFactory of type " + JedisConnectionFactory.class.getName() + " or " + LettuceConnectionFactory.class.getName() + " but was of type " + connector.getClass().getName());
    }
}
Also used : JedisConnectionFactory(org.springframework.data.redis.connection.jedis.JedisConnectionFactory) LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)

Example 5 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.

the class RedisAutoConfigurationTests method testRedisConfigurationWithCustomBean.

@Test
void testRedisConfigurationWithCustomBean() {
    this.contextRunner.withUserConfiguration(RedisStandaloneConfig.class).run((context) -> {
        LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
        assertThat(cf.getHostName()).isEqualTo("foo");
    });
}
Also used : LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) Test(org.junit.jupiter.api.Test)

Aggregations

LettuceConnectionFactory (org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)27 Test (org.junit.jupiter.api.Test)16 JedisConnectionFactory (org.springframework.data.redis.connection.jedis.JedisConnectionFactory)5 Bean (org.springframework.context.annotation.Bean)4 RedisStandaloneConfiguration (org.springframework.data.redis.connection.RedisStandaloneConfiguration)3 Test (org.junit.Test)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 ServiceConnectorCreationException (org.springframework.cloud.service.ServiceConnectorCreationException)2 LettuceClientConfiguration (org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration)2 LettuceClientConfigurationBuilder (org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder)2 LoadingCacheTest (com.alicp.jetcache.LoadingCacheTest)1 RefreshCacheTest (com.alicp.jetcache.RefreshCacheTest)1 AbstractExternalCacheTest (com.alicp.jetcache.test.external.AbstractExternalCacheTest)1 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)1 ConfigurationPropertyFactoryBean (org.hisp.dhis.external.conf.ConfigurationPropertyFactoryBean)1 Pool (org.springframework.boot.autoconfigure.data.redis.RedisProperties.Pool)1 Cloud (org.springframework.cloud.Cloud)1 CloudFactory (org.springframework.cloud.CloudFactory)1 PooledServiceConnectorConfig (org.springframework.cloud.service.PooledServiceConnectorConfig)1 Profile (org.springframework.context.annotation.Profile)1