发表于: 2019-11-22 23:57:02
1 1112
今天完成的事情:
在服务器上使用jmeter测压完成
之前一直用的都是外网ip,所以吞吐量一直都上不去
听了师兄的教导后换成内网ip 127.0.0.1后测试特别流畅
以下1,3条数据为无缓存,我使用的是20线程循环50此,虽然效果不是很明显,但还是能看出来加了缓存后效率明显要好一点
spring整合redis
redis.properties
#最大能够保持idel状态的对象数
redis.maxIdle=800
redis.minIdle=100
#当池内没有返回对象时,最大等待时间
redis.maxWaitMillis=3000
#当调用borrow Object方法时,是否进行有效性检查
redis.testOnBorrow=true
#最大活动对象数
redis.maxTotal=128
redis.host=127.0.0.1
redis.port=6379
redis.password=123456
redis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com"/>
<context:property-placeholder location="classpath:redis.properties" ignore-unresolvable="true"/>
<!--设置数据池-->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.maxIdle}"></property>
<property name="minIdle" value="${redis.minIdle}"></property>
<property name="maxTotal" value="${redis.maxTotal}"></property>
<property name="maxWaitMillis" value="${redis.maxWaitMillis}"></property>
<property name="testOnBorrow" value="${redis.testOnBorrow}"></property>
</bean>
<!--链接redis-->
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${redis.host}"></property>
<property name="port" value="${redis.port}"></property>
<property name="password" value="${redis.password}"></property>
<property name="poolConfig" ref="poolConfig"></property>
</bean>
<!-- redis 序列化策略 ,手动指定 key 采用String序列化策略 -->
<bean id="stringSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" >
<property name="connectionFactory" ref="connectionFactory"/>
<property name="keySerializer" ref="stringSerializer"/>
<!-- 开启事务,可以通过transcational注解控制 -->
<property name="enableTransactionSupport" value="true"/>
</bean>
</beans>
在springmvc配置文件里整合
需要用到的依赖
明天计划的事情:把缓存逻辑写到代码里,测试完尽快交任务
遇到的问题:无
收获:无
评论