1.remove init method

main
Gary 9 months ago
parent a6537e3461
commit b792b647f5

@ -45,10 +45,9 @@ public class SaticScheduleTask {
@Autowired
private TagDao tagDao;
@PostConstruct
private void init() {
updateAutoComplete();
}
/*
* @PostConstruct private void init() { updateAutoComplete(); }
*/
// 1.凌晨4点执行更新期刊tag
@Scheduled(cron = "0 0 4 * * *")
@ -61,27 +60,29 @@ public class SaticScheduleTask {
}
// 2.凌晨4:20点执行更新分词
@Scheduled(cron = "0 20 4 * * *")
private void updateAutoComplete() {
Stream<Entry<String, Set<String>>> journalSongStream = journalSongDao.findAll().parallelStream()
.map(j -> getJournalSongMap(j)).flatMap(m -> m.entrySet().stream());
Stream<Entry<String, Set<String>>> journalStream = journalDao.findValidJournals().parallelStream()
.map(j -> getJournalMap(j)).flatMap(m -> m.entrySet().stream());
Map<String, List<Entry<String, Set<String>>>> map = Stream.concat(journalSongStream, journalStream)
.collect(Collectors.groupingBy(e -> e.getKey()));
int keyCount = map.size();
int cacheKeyCount = cacheChannel.keys(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE).size();
if (keyCount != cacheKeyCount) {
map.entrySet().parallelStream().forEach(e -> {
List<String> value = e.getValue().stream().flatMap(a -> a.getValue().stream()).distinct().sorted()
.collect(Collectors.toList());
cacheChannel.set(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE, e.getKey(), value);
});
}
}
/*
* @Scheduled(cron = "0 20 4 * * *") private void updateAutoComplete() {
* Stream<Entry<String, Set<String>>> journalSongStream =
* journalSongDao.findAll().parallelStream() .map(j ->
* getJournalSongMap(j)).flatMap(m -> m.entrySet().stream());
*
* Stream<Entry<String, Set<String>>> journalStream =
* journalDao.findValidJournals().parallelStream() .map(j ->
* getJournalMap(j)).flatMap(m -> m.entrySet().stream());
*
* Map<String, List<Entry<String, Set<String>>>> map =
* Stream.concat(journalSongStream, journalStream)
* .collect(Collectors.groupingBy(e -> e.getKey()));
*
* int keyCount = map.size(); int cacheKeyCount =
* cacheChannel.keys(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE).
* size(); if (keyCount != cacheKeyCount) {
* map.entrySet().parallelStream().forEach(e -> { List<String> value =
* e.getValue().stream().flatMap(a -> a.getValue().stream()).distinct().sorted()
* .collect(Collectors.toList());
* cacheChannel.set(constants.Constants.J2CACHE_REGION_SEARCH_AUTO_COMPLETE,
* e.getKey(), value); }); } }
*/
private Map<String, Set<String>> getJournalMap(Journal j) {
Map<String, Set<String>> map = new HashMap<>();

Loading…
Cancel
Save