Example usage for org.springframework.data.redis.connection RedisStandaloneConfiguration RedisStandaloneConfiguration

List of usage examples for org.springframework.data.redis.connection RedisStandaloneConfiguration RedisStandaloneConfiguration

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection RedisStandaloneConfiguration RedisStandaloneConfiguration.

Prototype

public RedisStandaloneConfiguration() 

Source Link

Document

Create a new default RedisStandaloneConfiguration .

Usage

From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java

@Test // DATAREDIS-667
public void factoryCreatesPooledConnections() {

    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();

    LettuceClientConfiguration configuration = LettucePoolingClientConfiguration.builder()
            .poolConfig(poolConfig).clientResources(LettuceTestClientResources.getSharedClientResources())
            .shutdownTimeout(Duration.ZERO).build();

    LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration(),
            configuration);/* w  w  w.  ja  v  a 2  s . c  o m*/
    factory.setShareNativeConnection(false);
    factory.afterPropertiesSet();

    ConnectionFactoryTracker.add(factory);

    RedisConnection initial = factory.getConnection();
    Object initialNativeConnection = initial.getNativeConnection();

    initial.close();

    RedisConnection subsequent = factory.getConnection();
    Object subsequentNativeConnection = subsequent.getNativeConnection();

    subsequent.close();

    assertThat(initialNativeConnection, is(subsequentNativeConnection));

    factory.destroy();
}

From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java

@Test // DATAREDIS-576
public void connectionAppliesClientName() {

    LettuceClientConfiguration configuration = LettuceClientConfiguration.builder()
            .clientResources(LettuceTestClientResources.getSharedClientResources()).clientName("clientName")
            .build();// ww  w.java  2 s  . c  om

    LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration(),
            configuration);
    factory.setShareNativeConnection(false);
    factory.afterPropertiesSet();

    ConnectionFactoryTracker.add(factory);

    RedisConnection connection = factory.getConnection();

    assertThat(connection.getClientName(), is(equalTo("clientName")));
    connection.close();
}

From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java

@Test // DATAREDIS-576
public void getClientNameShouldEqualWithFactorySetting() {

    LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration());
    factory.setClientResources(LettuceTestClientResources.getSharedClientResources());
    factory.setClientName("clientName");
    factory.afterPropertiesSet();// ww  w  .  jav a  2s  . com

    ConnectionFactoryTracker.add(factory);

    RedisConnection connection = factory.getConnection();
    assertThat(connection.getClientName(), equalTo("clientName"));

    connection.close();
}