spring-data-redis + Jedis配置文件

相比網上的,新版本好像有些字段更改了名字,不知是否正確,歡迎指正redis

###application.xml###spring

<!-- spring data redis -->
    <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
        <property name="usePool" value="true"></property>
        <property name="hostName" value="${redis.host}" />
        <property name="port" value="${redis.port}" />
        <property name="password" value="${redis.pass}" />
        <property name="timeout" value="${redis.timeout}" />
        <property name="database" value="${redis.default.db}"></property>
        <constructor-arg index="0" ref="jedisPoolConfig" />
    </bean>

    <!-- jedis pool配置 -->
    <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
        <property name="maxTotal" value="${redis.maxActive}" />
        <property name="maxIdle" value="${redis.maxIdle}" />
        <property name="maxWaitMillis" value="${redis.maxWait}" />
        <!--
        <property name="testOnBorrow" value="${redis.testOnBorrow}" />
        -->
    </bean>

    <!-- Redis Template -->
    <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
        <property name="connectionFactory" ref="jedisConnectionFactory" />
    </bean>

相比網上搜索的結果,其中有兩處更改,均在jedisPoolConfig數據庫

  • maxActive更換成了maxTotal
  • maxWait更換成了maxWaitMillis ###redis.properties###
#redis的服務器地址
redis.host=192.168.1.105
#redis的服務端口
redis.port=6379
#密碼
redis.pass=1234xxxxx
#連接數據庫
redis.default.db=0
#客戶端超時時間單位是毫秒
redis.timeout=100000
#最大鏈接數
redis.maxActive=300
#最大空閒數
redis.maxIdle=100
#最大創建鏈接等待時間
redis.maxWait=1000
#指明是否在從池中取出鏈接前進行檢驗,若是檢驗失敗,則從池中去除鏈接並嘗試取出另外一個
#DBSync.testOnBorrow=true
相關文章
相關標籤/搜索