mirror of
https://github.com/201206030/novel-plus.git
synced 2026-02-07 16:52:24 +08:00
perf: 优化缓存模块
提升可读性 & 减小内存占用
This commit is contained in:
@@ -72,17 +72,15 @@ public class CrawlController {
|
||||
if(url.startsWith("https://")||url.startsWith("http://")){
|
||||
String refreshCache="1";
|
||||
if(!refreshCache.equals(isRefresh)) {
|
||||
Object cache = cacheService.getObject(CacheKey.BOOK_TEST_PARSE + url);
|
||||
if (cache == null) {
|
||||
html = cacheService.get(CacheKey.BOOK_TEST_PARSE + url);
|
||||
if (html == null) {
|
||||
isRefresh="1";
|
||||
}else {
|
||||
html = (String) cache;
|
||||
}
|
||||
}
|
||||
if(refreshCache.equals(isRefresh)){
|
||||
html = HttpUtil.getByHttpClientWithChrome(url);
|
||||
if (html != null) {
|
||||
cacheService.setObject(CacheKey.BOOK_TEST_PARSE + url, html, 60 * 10);
|
||||
cacheService.set(CacheKey.BOOK_TEST_PARSE + url, html, 60 * 10);
|
||||
}else{
|
||||
resultMap.put("msg","html is null");
|
||||
return RestResult.ok(resultMap);
|
||||
|
||||
Reference in New Issue
Block a user