es采集优化

This commit is contained in:
xxy 2020-05-25 23:38:46 +08:00
parent 9b9851e7ab
commit 8f1ed88b07
2 changed files with 9 additions and 2 deletions

View File

@ -49,7 +49,7 @@ public class BookToEsSchedule {
@Scheduled(fixedRate = 1000 * 60)
public void saveToEs() {
if (cacheService.get(CacheKey.ES_TRANS_LOCK) == null) {
cacheService.set(CacheKey.ES_TRANS_LOCK, "1", 60 * 5);
cacheService.set(CacheKey.ES_TRANS_LOCK, "1", 60 * 20);
try {
//查询需要更新的小说
Date lastDate = (Date) cacheService.getObject(CacheKey.ES_LAST_UPDATE_TIME);
@ -62,7 +62,7 @@ public class BookToEsSchedule {
for (Book book : books) {
searchService.importToEs(book);
lastDate = book.getUpdateTime();
Thread.sleep(1000);
Thread.sleep(5000);
}

View File

@ -16,5 +16,12 @@ public interface SearchService {
*/
void importToEs(Book book);
/**
* 搜索
* @param params 搜索参数
* @param page 当前页码
* @param pageSize 每页大小
* @return 分页信息
*/
PageInfo searchBook(BookSP params, int page, int pageSize);
}