今天学习了同事在程序中使用redis做缓存的代码,是将查询出来的列表放在缓存里,以便于下次查询更加速度。比较常用到,整理一下下。
一、在xml文件中配置
<beans profile="redis">
<bean class="cn.com.jdls.foundation.cache2.plugcache.redis.RedisBean" >
<property name="jedisConnectionFactory" ref="mhRedisConnectionFactory"></property>
</bean>
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="${mh.redis.maxTotal}"></property>
<property name="maxIdle" value="${mh.redis.maxIdle}"></property>
<property name="maxWaitMillis" value="${mh.redis.maxWait}"></property>
<property name="minEvictableIdleTimeMillis" value="300000"></property>
<property name="numTestsPerEvictionRun" value="3"></property>
<property name="timeBetweenEvictionRunsMillis" value="60000"></property>
</bean>
<bean id="mhRedisConnectionFactory"
class=