Skip to content
This repository was archived by the owner on Nov 21, 2020. It is now read-only.

Commit 9aa5108

Browse files
committed
fix: collection cache add
1 parent 6b40972 commit 9aa5108

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/org/code4everything/boot/cache/BootCacheManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import cn.hutool.core.collection.ConcurrentHashSet;
55
import cn.hutool.core.util.ObjectUtil;
66
import cn.hutool.core.util.StrUtil;
7+
import com.google.common.collect.Lists;
78
import org.code4everything.boot.base.bean.BaseDomain;
89
import org.code4everything.boot.base.constant.StringConsts;
910
import org.springframework.cache.Cache;
@@ -146,8 +147,11 @@ public void addVal(String cacheName, String key, Object value) {
146147
Cache cache = getCache(cacheName);
147148
if (ObjectUtil.isNotNull(cache)) {
148149
Object object = cache.get(key);
149-
if (object instanceof Collection) {
150+
if (Objects.isNull(object)) {
151+
putVal(cacheName, key, Lists.newArrayList(value));
152+
} else if (object instanceof Collection) {
150153
((Collection) object).add(value);
154+
putVal(cacheName, key, object);
151155
}
152156
}
153157
}

0 commit comments

Comments
 (0)