List of usage examples for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory setShareNativeConnection
public void setShareNativeConnection(boolean shareNativeConnection)
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);/*from www .j a v a2 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-687 public void connectsThroughRedisSocket() { assumeTrue(EpollProvider.isAvailable() || KqueueProvider.isAvailable()); assumeTrue(new File(SettingsUtils.getSocket()).exists()); LettuceClientConfiguration configuration = LettuceTestClientConfiguration.create(); LettuceConnectionFactory factory = new LettuceConnectionFactory(SettingsUtils.socketConfiguration(), configuration);/*from ww w .j a va 2 s. c om*/ factory.setShareNativeConnection(false); factory.afterPropertiesSet(); RedisConnection connection = factory.getConnection(); assertThat(connection.ping(), is(equalTo("PONG"))); connection.close(); 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();// www.j a va 2 s . c o m 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(); }