发表于: 2017-10-28 23:28:39
2 800
今天完成的事
学习序列化和反序列化,完成memcache
刚开始找了一个序列化的工具类,但是不太好用,在序列化list<>的时候还要先转换为数组才可以,非常麻烦,索性用了程远师兄说的阿里巴巴fastjson自带的序列化方法将查询出对象实例化
先写的测试类
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring-mybatis.xml"})
public class SerializeTest {
private Logger logtest = Logger.getLogger(ProfessionTest.class);
@Autowired
private StudentMapper studentMapper;
@Test
public void allStudent() throws IOException{
List<Student> student1 = null ;
student1 = studentMapper.allStudent();
//先从缓存中获取数据
logtest.info("从缓存获取数据");
String mes =(String) MemCacheUtil.get("allStudent");
//进行序列化
logtest.info("开始序列化");
String mes2 = JSON.toJSONString(student1);
logtest.info("存入缓存");
Boolean status = MemCacheUtil.set("allStudent",mes2);
logtest.info("存入状态"+status);
}
}
之后直接在telnet查询存入的数据
相继更改了/a/home ;/a/login ; 以及免登录页面
进行一波压测
180线程,无限循环,TPS达到了350+,确实效果惊人,至于90%line,因为忘了在之前本地测试的线程数,无法进行对比,这个明天部署到服务器再压测一波
遇到的问题:
网上的序列化工具类不好使,无法直接序列化List<>,卡了一段时间,换成了fastjson
明天的计划:
部署到服务器,进行压测,写出压测报告
准备小课堂
收获:序列化和反序列化,完成memcache
任务进度:任务6步骤2
任务开始时间:2017-10-21
预计demo时间:2017-10-26
第一次延期5天到10.31
禅道:http://task.ptteng.com/zentao/project-task-276.html
评论