| | |
| | | log.info("开始存学习时长"); |
| | | List<StudyRecord> cacheList = new ArrayList<>(); |
| | | // 取出所有学习记录缓存项 |
| | | ConcurrentMap<String, Object> map = caffeineCache.asMap(); |
| | | Map<String,StudyRecord> studyMap = (Map<String, StudyRecord>) map.get(CaffeineConstant.STUDY_RECORD); |
| | | Map<String, StudyRecord> studyMap = (Map<String, StudyRecord>) caffeineCache.getIfPresent(CaffeineConstant.STUDY_RECORD); |
| | | if (!CollectionUtils.isEmpty(studyMap)) { |
| | | for (Map.Entry<String, StudyRecord> entry : studyMap.entrySet()) { |
| | | cacheList.add(entry.getValue()); |
| | | } |
| | |
| | | studyRecordService.saveOrUpdateBatch(cacheList); |
| | | } |
| | | caffeineCache.invalidate(CaffeineConstant.STUDY_RECORD); |
| | | } |
| | | log.info("结束存学习时长"); |
| | | } |
| | | } |