Use Connection pool with Jedis

情到浓时终转凉″ 提交于 2019-12-05 13:35:36
Radhika Mantri
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost", portno, 10000,
            "password");

See here: https://github.com/xetorthio/jedis/wiki/Getting-started

Check out Spring-data-redis.

When you add a JedisConnectionFactory you get a connectionFactory which has connection pooling capability by default.

JedisConnectionFactory() Constructs a new JedisConnectionFactory instance with default settings (default connection pooling, no shard information). See docs.

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:p="http://www.springframework.org/schema/p"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:use-pool="true" p:host-name="server" p:port="6379"/>

</beans>

For further information, see the documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!