mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
refactor: 使用类型推断 var
This commit is contained in:
parent
d9202c76fa
commit
c572650107
@ -37,7 +37,8 @@ public class CacheConfig {
|
||||
SimpleCacheManager cacheManager = new SimpleCacheManager();
|
||||
|
||||
List<CaffeineCache> caches = new ArrayList<>(CacheConsts.CacheEnum.values().length);
|
||||
for (CacheConsts.CacheEnum c : CacheConsts.CacheEnum.values()) {
|
||||
// 类型推断 var 非常适合 for 循环,JDK 10 引入,JDK 11 改进
|
||||
for (var c : CacheConsts.CacheEnum.values()) {
|
||||
if (c.isLocal()) {
|
||||
Caffeine<Object, Object> caffeine = Caffeine.newBuilder().recordStats().maximumSize(c.getMaxSize());
|
||||
if (c.getTtl() > 0) {
|
||||
@ -62,7 +63,8 @@ public class CacheConfig {
|
||||
.disableCachingNullValues().prefixCacheNameWith(CacheConsts.REDIS_CACHE_PREFIX);
|
||||
|
||||
Map<String, RedisCacheConfiguration> cacheMap = new LinkedHashMap<>(CacheConsts.CacheEnum.values().length);
|
||||
for (CacheConsts.CacheEnum c : CacheConsts.CacheEnum.values()) {
|
||||
// 类型推断 var 非常适合 for 循环,JDK 10 引入,JDK 11 改进
|
||||
for (var c : CacheConsts.CacheEnum.values()) {
|
||||
if (c.isRemote()) {
|
||||
if (c.getTtl() > 0) {
|
||||
cacheMap.put(c.getName(), RedisCacheConfiguration.defaultCacheConfig().disableCachingNullValues()
|
||||
|
@ -77,7 +77,8 @@ public class EsSearchServiceImpl implements SearchService {
|
||||
|
||||
List<BookInfoRespDto> list = new ArrayList<>();
|
||||
List<Hit<EsBookDto>> hits = response.hits().hits();
|
||||
for (Hit<EsBookDto> hit : hits) {
|
||||
// 类型推断 var 非常适合 for 循环,JDK 10 引入,JDK 11 改进
|
||||
for (var hit : hits) {
|
||||
EsBookDto book = hit.source();
|
||||
assert book != null;
|
||||
if (!CollectionUtils.isEmpty(hit.highlight().get(EsConsts.BookIndex.FIELD_BOOK_NAME))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user