redis.propertiesjava
#IP地址 redis.pool.host=192.168.0.223 #端口號 redis.pool.port=6379 #redis.pool.pass=123456 #最大可以保持idel狀態的對象數 redis.pool.maxIdle=300 #最大分配的對象數 redis.pool.maxTotal=600 #多長時間檢查一次鏈接池中空閒的鏈接 redis.pool.timeBetweenEvictionRunsMillis=30000 #空閒鏈接多長時間後會被收回 redis.pool.minEvictableIdleTimeMillis=30000 #當調用borrow Object方法時,是否進行有效性檢查 redis.pool.testOnBorrow=true ########reids編碼格式 redis.encode=utf-8 ######緩存過時時間 秒 1000*60*60*24*7 七天 redis.expire=604800000 ####是否開啓Redis服務應用 redis.unlock=false
spring.xml
redis
<!-- Redis緩存配置 --> <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.pool.host}" /> <property name="port" value="${redis.pool.port}" /> <property name="poolConfig" ref="jedisPoolConfig" /> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="jedisConnFactory" /> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.pool.maxTotal}" /> <property name="maxIdle" value="${redis.pool.maxIdle}" /> <property name="timeBetweenEvictionRunsMillis" value="${redis.pool.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${redis.pool.minEvictableIdleTimeMillis}" /> <property name="testOnBorrow" value="${redis.pool.testOnBorrow}" /> </bean>