1.remove dirty cache

main
Gary 9 months ago
parent 3c1516c15c
commit 43b10cbbde

@ -107,6 +107,7 @@ public class SaticScheduleTask {
journal.setNameChTags(tagStr); journal.setNameChTags(tagStr);
journalDao.save(journal); journalDao.save(journal);
this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, journal.getId()); this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, journal.getId());
this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journal.getJournalNo());
updateCounter.incrementAndGet(); updateCounter.incrementAndGet();
} }
} }

@ -66,6 +66,8 @@ public class CMSJournalController {
public Result update(@ApiParam(value = "期刊ID", required = true) @PathVariable String id, public Result update(@ApiParam(value = "期刊ID", required = true) @PathVariable String id,
@ApiParam(value = "期刊信息", required = true) @RequestBody JournalAddModel updateModel){ @ApiParam(value = "期刊信息", required = true) @RequestBody JournalAddModel updateModel){
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id);
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id));
return journalService.update(id, updateModel); return journalService.update(id, updateModel);
} }
@ -75,6 +77,8 @@ public class CMSJournalController {
@ApiParam(value = "期刊发布请求对象", required = true) @RequestBody JournalPublishReq queryModel){ @ApiParam(value = "期刊发布请求对象", required = true) @RequestBody JournalPublishReq queryModel){
cacheChannel.evict("default", "journal_filter"); cacheChannel.evict("default", "journal_filter");
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id);
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id));
return journalService.publish(id, queryModel); return journalService.publish(id, queryModel);
} }
@ -83,6 +87,8 @@ public class CMSJournalController {
public Result updateColumnState(@ApiParam(value = "期刊ID", required = true) @PathVariable String id, public Result updateColumnState(@ApiParam(value = "期刊ID", required = true) @PathVariable String id,
@ApiParam(value = "期刊启停状态0:停用1:启用", required = true) @RequestBody String state){ @ApiParam(value = "期刊启停状态0:停用1:启用", required = true) @RequestBody String state){
cacheChannel.evict("default", "journal_filter"); cacheChannel.evict("default", "journal_filter");
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id);
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id));
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
return journalService.updateJournalState(id, state); return journalService.updateJournalState(id, state);
} }
@ -91,6 +97,8 @@ public class CMSJournalController {
@RequestMapping(value="/{id}", method= RequestMethod.DELETE) @RequestMapping(value="/{id}", method= RequestMethod.DELETE)
public Result delete(@ApiParam(value = "期刊ID", required = true) @PathVariable String id){ public Result delete(@ApiParam(value = "期刊ID", required = true) @PathVariable String id){
cacheChannel.evict("default", "journal_filter"); cacheChannel.evict("default", "journal_filter");
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id);
cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journalService.findJournalNoById(id));
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE); cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
return journalService.deleteById(id); return journalService.deleteById(id);
} }

@ -88,5 +88,8 @@ public interface JournalDao extends JpaRepository<Journal,String>,JpaSpecificati
@Query(value = "select * from tb_journal where match(journal_no, title) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true) @Query(value = "select * from tb_journal where match(journal_no, title) against(?1 IN BOOLEAN MODE) limit ?2,?3 ", nativeQuery = true)
List<Journal> fuzzySearch(String keyword, int offset, int limit); List<Journal> fuzzySearch(String keyword, int offset, int limit);
@Query(value = "select journal_no FROM tb_journal where id=?1", nativeQuery = true)
String findJournalNoById(String journalId);
} }

@ -34,6 +34,7 @@ public class CleanJournalQueryPageListener {
String journalQueryPageKey = getJournalQueryPageKey(optional.get()); String journalQueryPageKey = getJournalQueryPageKey(optional.get());
cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, journalQueryPageKey); cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, journalQueryPageKey);
cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_ID,journalId); cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_ID,journalId);
cacheChannel.evict(Constants.J2CACHE_REGION_JOURNAL_NO,optional.get().getJournalNo());
} }
private String getJournalQueryPageKey(Journal journal) { private String getJournalQueryPageKey(Journal journal) {

@ -424,6 +424,7 @@ public class CMSJournalService {
newJournal.setPubTime(oldJournal.getPubTime()); newJournal.setPubTime(oldJournal.getPubTime());
Journal journal = journalDao.save(newJournal); Journal journal = journalDao.save(newJournal);
this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id); this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_ID, id);
this.cacheChannel.evict(constants.Constants.J2CACHE_REGION_JOURNAL_NO,journal.getJournalNo());
// 删除旧的关联信息,更新的关联信息 // 删除旧的关联信息,更新的关联信息
batchDeleteJournalRelatesInfo(id, oldJournal.getJournalNo()); batchDeleteJournalRelatesInfo(id, oldJournal.getJournalNo());
batchSaveJournalRelatesInfo(id, param); batchSaveJournalRelatesInfo(id, param);
@ -485,4 +486,9 @@ public class CMSJournalService {
} }
return Result.success(); return Result.success();
} }
public String findJournalNoById(String journalId) {
String journalNo = journalDao.findJournalNoById(journalId);
return null==journalNo?"invalidJournalNo":journalNo;
}
} }

Loading…
Cancel
Save