Redis2.8 integrated configuration of single Redis Jedispool with spring

Source: Internet
Author: User

1,spring Configuration

<bean id= "Jedispoolconfig" class= "Redis.clients.jedis.JedisPoolConfig" >
<!--control how many Jedis instances a pool can allocate--
<property name= "Maxtotal" value= "${redis.maxtotal}"/>
<!--controls the maximum number of Jedis instances in a pool that have a status of idle (idle)--
<property name= "Maxidle" value= "${redis.maxidle}"/>
<property name= "Minidle" value= "${redis.minidle}"/>
<!--indicates that when borrow a Jedis instance, the maximum wait time, if the wait time is exceeded, is thrown directly jedisconnectionexception--
<property name= "Maxwaitmillis" value= "${redis.maxwaitmillis}"/>
<!--whether validate operations are performed in advance when borrow an Jedis instance, and if true, the resulting Jedis instance is available--
<property name= "Testonborrow" value= "${redis.testonborrow}"/>
<property name= "Testonreturn" value= "${redis.testonreturn}"/>
<property name= "Testwhileidle" value= "${redis.testwhileidle}"/>
</bean>


<!--Redis connection pool pools, not required: Timeout/password--
<bean id = "Jedispool" class= "Redis.clients.jedis.JedisPool" >
<constructor-arg index= "0" ref= "jedispoolconfig"/>
<constructor-arg index= "1" value= "${redis.host}"/>
<constructor-arg index= "2" value= "${redis.port}" type= "int"/>
<constructor-arg index= "3" value= "${redis.timeout}" type= "int"/>
<constructor-arg index= "4" value= "${redis.password}"/>
</bean>


2, using


Jedis Redis = Jedispool.getresource ();
Redis.hset ("test002", "Pos2", "002");


Attention:

1, in order for the client to access the Redis in a password way, you need to configure the Dongdong

A: Locate the redis.conf configuration file,

Where, attributes,

Requirepass Password # Configuration Redis Password for connection

B: Run the client, performing the following 2 commands, respectively:

CONFIG SET requirepass "Password"
AUTH "Password"

C: Later, each time the client connects, run the REDIS-CLI command, you need to execute the command first

AUTH "Password"

In order to continue the subsequent operation


2, in addition, common configuration options

Daemonize Yes # Redis whether the next process runs

AppendOnly Yes #是否启用aof日志


Redis2.8 integrated configuration of single Redis Jedispool with spring

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.