spring-redis.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:cache="http://www.springframework.org/schema/cache"
  7. xsi:schemaLocation="
  8. http://www.springframework.org/schema/beans
  9. http://www.springframework.org/schema/beans/spring-beans.xsd
  10. http://www.springframework.org/schema/cache
  11. http://www.springframework.org/schema/cache/spring-cache.xsd
  12. http://www.springframework.org/schema/context
  13. http://www.springframework.org/schema/context/spring-context-4.1.xsd">
  14. <cache:annotation-driven cache-manager="redisCacheManager" />
  15. <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
  16. <property name="maxTotal" value="${redis.pool.maxTotal}" />
  17. <property name="maxIdle" value="${redis.pool.maxIdle}" />
  18. <!-- <property name="maxWait" value="${redis.pool.maxWait}" /> -->
  19. <property name="testOnBorrow" value="${redis.pool.testOnBorrow}" />
  20. </bean>
  21. <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration" />
  22. <!-- <bean id="shardedJedisPool" class="redis.clients.jedis.ShardedJedisPool" scope="singleton"> -->
  23. <!-- <constructor-arg index="0" ref="jedisPoolConfig" /> -->
  24. <!-- <constructor-arg index="1"> -->
  25. <!-- <list> -->
  26. <!-- <bean class="redis.clients.jedis.JedisShardInfo"> -->
  27. <!-- <constructor-arg name="host" value="${redis.hostname}" /> -->
  28. <!-- <constructor-arg name="port" value="${redis.port}" /> -->
  29. <!-- <constructor-arg name="timeout" value="${redis.timeout}" /> -->
  30. <!-- <constructor-arg name="weight" value="1" /> -->
  31. <!-- <property name="password" value="${redis.password}" /> -->
  32. <!-- </bean> -->
  33. <!-- </list> -->
  34. <!-- </constructor-arg> -->
  35. <!-- </bean> -->
  36. <bean id="jedisConnectionFactory"
  37. class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
  38. <property name="hostName" value="${redis.hostname}" />
  39. <property name="port" value="${redis.port}" />
  40. <property name="password" value="${redis.password}" />
  41. <property name="poolConfig" ref="jedisPoolConfig" />
  42. </bean>
  43. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"
  44. p:connection-factory-ref="jedisConnectionFactory" />
  45. <bean id="redisCacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
  46. <constructor-arg ref="redisTemplate"></constructor-arg>
  47. <property name="usePrefix" value="true" />
  48. <property name="defaultExpiration" value="${redis.expiration}" />
  49. </bean>
  50. </beans>