Java Code Examples for org.springframework.data.redis.connection.jedis.JedisConnectionFactory#setUsePool()

The following examples show how to use org.springframework.data.redis.connection.jedis.JedisConnectionFactory#setUsePool() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisSessionConfiguration.java    From personal_book_library_web_project with MIT License 5 votes vote down vote up
@Bean
  public JedisConnectionFactory connectionFactory() {

JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName(env.getProperty("redis.host"));
jedisConnectionFactory.setPort(Integer.parseInt(env.getProperty("redis.port")));
jedisConnectionFactory.setUsePool(true);
return jedisConnectionFactory;
  }
 
Example 2
Source File: AppConfig.java    From Redis-4.x-Cookbook with MIT License 5 votes vote down vote up
@Bean
   JedisConnectionFactory jedisConnectionFactory(){
	JedisConnectionFactory factory = new JedisConnectionFactory();
	factory.setHostName(redisHost);
	factory.setPort(redisPort);
	factory.setUsePool(true);
	return factory;
}
 
Example 3
Source File: RedisConfiguration.java    From heimdall with Apache License 2.0 5 votes vote down vote up
/**
 * Configures and returns a {@link JedisConnectionFactory}.
 * 
 * @return {@link JedisConnectionFactory}
 */
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
     
     JedisConnectionFactory factory = new JedisConnectionFactory();
     
     factory.setHostName(property.getRedis().getHost());
     factory.setPort(property.getRedis().getPort());
     factory.setUsePool(true);
     factory.setPoolConfig(jediPoolConfig());
     return factory;
}
 
Example 4
Source File: RedisConfiguration.java    From heimdall with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link JedisConnectionFactory}.
 * 
 * @return {@link JedisConnectionFactory}
 */
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
     
     JedisConnectionFactory factory = new JedisConnectionFactory();
     
     factory.setHostName(property.getRedis().getHost());
     factory.setPort(property.getRedis().getPort());
     factory.setUsePool(true);
     factory.setPoolConfig(jediPoolConfig());
     return factory;
}
 
Example 5
Source File: RedisConfig.java    From Resource with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory()
{
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(env.getProperty("redis.host").trim());
    jedisConnectionFactory.setPort(Integer.parseInt(env.getProperty("redis.port").trim()));
    jedisConnectionFactory.setPassword(env.getProperty("redis.password").trim());
    jedisConnectionFactory.setDatabase(Integer.parseInt(env.getProperty("redis.database").trim()));
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.setPoolConfig(jedisPoolConfig);
    return jedisConnectionFactory;
}
 
Example 6
Source File: RedisConfiguration.java    From expper with GNU General Public License v3.0 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(redisProperties.getHost());
    factory.setPort(redisProperties.getPort());
    factory.setPassword(redisProperties.getPassword());
    factory.setUsePool(true);
    return factory;
}
 
Example 7
Source File: SessionConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
@Primary
public JedisConnectionFactory connectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(properties.getProperty("spring.redis.host","localhost"));
    factory.setPort(properties.getProperty("spring.redis.port", Integer.TYPE,6379));
    factory.afterPropertiesSet();
    factory.setUsePool(true);
    return factory;
}
 
Example 8
Source File: RedisCacheConfig.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
	// JedisPoolConfig poolConfig=new JedisPoolConfig();
	// poolConfig.set

	JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
	connectionFactory.setHostName("192.168.1.103");
	connectionFactory.setUsePool(true);
	return connectionFactory;
}
 
Example 9
Source File: RedisConfig.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
	JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
	connectionFactory.setHostName("192.168.1.103");
	connectionFactory.setUsePool(true);
	return connectionFactory;
}
 
Example 10
Source File: RedisCursorManagerIT.java    From fahrschein with Apache License 2.0 3 votes vote down vote up
@Test
@Ignore("Meant for local testing. You need a running redis cluster on localhost.")
public void connectToRedisAndUseCursorManager() throws IOException {

    final JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.setShardInfo(new JedisShardInfo("localhost", 6379));
    final CursorManager cursorManager = new RedisCursorManager(jedisConnectionFactory, "fahrschein_redis_test");

    Collection<Cursor> cursors;

    // Precondition

    cursors = cursorManager.getCursors(EVENT_TYPE_NAME);

    assertThat("Precondition failed. Redis is not empty for event type " + EVENT_TYPE_NAME, cursors, empty());

    // First round - initial cursors

    final Cursor cursor1 = new Cursor("partition1", "101");
    final Cursor cursor2 = new Cursor("partition2", "202");
    final Cursor cursor3 = new Cursor("partition3", "303");

    cursorManager.onSuccess(EVENT_TYPE_NAME, cursor1);
    cursorManager.onSuccess(EVENT_TYPE_NAME, cursor2);
    cursorManager.onSuccess(EVENT_TYPE_NAME, cursor3);

    assertThat(cursorManager.getCursors(EVENT_TYPE_NAME), containsInAnyOrder(cursor1, cursor2, cursor3));

    // Second round - update cursors

    final Cursor cursor4 = new Cursor("partition1", "102");
    final Cursor cursor5 = new Cursor("partition3", "304");

    cursorManager.onSuccess(EVENT_TYPE_NAME, cursor4);
    cursorManager.onSuccess(EVENT_TYPE_NAME, cursor5);

    assertThat(cursorManager.getCursors(EVENT_TYPE_NAME), containsInAnyOrder(cursor4, cursor2, cursor5));

}