Example usage for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory LettuceConnectionFactory

List of usage examples for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory LettuceConnectionFactory

Introduction

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

Prototype

@Deprecated
public LettuceConnectionFactory(LettucePool pool) 

Source Link

Usage

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

@Test
public void testCreateFactoryWithPool() {
    DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
    pool.setClientResources(LettuceTestClientResources.getSharedClientResources());
    pool.afterPropertiesSet();/*from   ww  w .j  a  va  2s .  c  om*/
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
    factory2.setShutdownTimeout(0);
    factory2.afterPropertiesSet();

    ConnectionFactoryTracker.add(factory2);

    RedisConnection conn2 = factory2.getConnection();
    conn2.close();
    factory2.destroy();
    pool.destroy();
}

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

@Ignore("Uncomment this test to manually check connection reuse in a pool scenario")
@Test/*from w w w  . ja va2s .  co m*/
public void testLotsOfConnections() throws InterruptedException {
    // Running a netstat here should show only the 8 conns from the pool (plus 2 from setUp and 1 from factory2
    // afterPropertiesSet for shared conn)
    DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
    pool.afterPropertiesSet();
    final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
    factory2.afterPropertiesSet();

    ConnectionFactoryTracker.add(factory2);

    for (int i = 1; i < 1000; i++) {
        Thread th = new Thread(() -> factory2.getConnection().bRPop(50000, "foo".getBytes()));
        th.start();
    }
    Thread.sleep(234234234);
}

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  . j a va  2  s .  co m*/

    ConnectionFactoryTracker.add(factory);

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

    connection.close();
}