发表于: 2017-11-10 23:29:16

1 727


今天完成的事情:

好吧,redis搞了一天。今天早上忽然就有了灵感,,,,把昨天那个环绕通知redis给搞定了。原因出在调用的不是服务层的方法而是service层的方法

但是还有问题,我在往redis里面存值的时候序列化失败,,我没有找到序列化数组的方法,,因为这个是别人封装好的。我自己改动需要 改动好多地方,,也不会改,所以只能按照师兄的方法重新搞redis。


    if (status == null) {
Integer getRedStudyStatus = Integer.parseInt(redisUtil.getValue("redStudyStatus") );
       logger.info("从缓存获取的在学人数" + getRedStudyStatus);
       if (getRedStudyStatus == null) {
Integer i = studentDao.countStudentStatus(status);
           boolean addRedStudyStatus = redisUtil.setCache("redStudyStatus",String.valueOf(i));
           logger.info("添加在学人数到缓存" + addRedStudyStatus);
           return i;
       } else {
return getRedStudyStatus;
       }
} else {
Integer getRedStudentsAllStatus = Integer.parseInt(redisUtil.getValue("redStudyStatus"));
       logger.info("从缓存中获取所有就业学员" + getRedStudentsAllStatus);
       if (getRedStudentsAllStatus == null) {
Integer i = studentDao.countStudentStatus(status);
           logger.info(i);
           boolean addRedStudentsAllStatus = redisUtil.setCache("redStudyStatus",String.valueOf(i));
           logger.info("添加就业到缓存" + addRedStudentsAllStatus);
           return i;
       } else {
return getRedStudentsAllStatus;
       }
}
}

一点一点将memcached改为redis的缓存,,直接拿师兄的工具类来使用。

public List<Student> listStudentAll() {
List<Student> students = null;
   String getRedStudentAll = redisUtil.getValue("memStudentAll");
   logger.info("缓存中获得所有学生" + getRedStudentAll);
   if (getRedStudentAll == "null") {
students = studentDao.listStudentAll();
       logger.info("从数据库获取全部学生" + students);
       String addRedStudentAll = JSON.toJSONString(students);
       boolean success = redisUtil.setCache("memStudentAll",addRedStudentAll);
       logger.info("将全部学生信息存入缓存" + success);
       return students;
   } else {
students = JSON.parseObject(getRedStudentAll, List.class);
       List<Student> studentAll = studentDao.listStudentAll();
       logger.info("查询到的所有学生" + studentAll);
       return studentAll;
   }

又卡在了配置文件。


明天计划完成的事情:

一定要把任务6结束。

准备小课堂  ,这次准备memcached。


问题:

还是数组序列化的问题,因为是在封装好的环绕通知里面,在尝试改动的时候发现真的是牵一发动全身,,搞不定,师兄给的建议换成阿里的FastJson进行序列化,,也尝试了一下,,还是不会搞。

现在还有一个问题。从redis里面没有获取到缓存时就会报错NULL

明天解决。


任务进度:任务6步骤3

任务开始时间:2017-11-4

预计demo时间:2017-11-12

是否有延期风险:暂无

禅道:http://task.ptteng.com/zentao/task-view-13097.html



返回列表 返回列表
评论

    分享到