From 7f8d2d61a11625792a8cdee2d7065a9e76ab6d8d Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 4 Nov 2025 18:28:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20Mybatis=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E7=BC=93=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1547226243891200]Mybatis二级缓存优化 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1547226243891200 --- .../java/neatlogic/framework/dao/cache/NeatLogicCache.java | 4 ++-- .../framework/dao/cache/NeatLogicConcurrentSafeCache.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java index a5884d0b3..065b42298 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java @@ -126,7 +126,7 @@ public class NeatLogicCache implements Cache { if (value instanceof List && ((List) value).isEmpty()) { return; } - getCache().put(key, value); + getCache().put(key, CacheUtils.deepCopy(value)); } @Override @@ -162,4 +162,4 @@ public class NeatLogicCache implements Cache { public String toString() { return "Ehcache3 {" + id + "}"; } -} \ No newline at end of file +} diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java index e9826018e..b9c37cb8f 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java @@ -183,7 +183,7 @@ public class NeatLogicConcurrentSafeCache implements Cache { @Override public void putObject(Object key, Object value) { if (value != null) { - getCache().put(key, value); + getCache().put(key, CacheUtils.deepCopy(value)); } String lockKey = generateLockKey(getId(), key); ReentrantLock lock = LOCAL_LOCK_MAP.get(lockKey); -- Gitee From 748b15f63b7026f94910159d7548d45407827bdf Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Tue, 4 Nov 2025 19:17:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20Mybatis=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E7=BC=93=E5=AD=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1547226243891200]Mybatis二级缓存优化 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1547226243891200 --- .../java/neatlogic/framework/dao/cache/NeatLogicCache.java | 6 +++++- .../framework/dao/cache/NeatLogicConcurrentSafeCache.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java index 065b42298..233eab2ad 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java @@ -126,7 +126,11 @@ public class NeatLogicCache implements Cache { if (value instanceof List && ((List) value).isEmpty()) { return; } - getCache().put(key, CacheUtils.deepCopy(value)); + if (!this.readOnly) { + getCache().put(key, CacheUtils.deepCopy(value)); + } else { + getCache().put(key, value); + } } @Override diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java index b9c37cb8f..e51fb3657 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java @@ -183,7 +183,11 @@ public class NeatLogicConcurrentSafeCache implements Cache { @Override public void putObject(Object key, Object value) { if (value != null) { - getCache().put(key, CacheUtils.deepCopy(value)); + if (!this.readOnly) { + getCache().put(key, CacheUtils.deepCopy(value)); + } else { + getCache().put(key, value); + } } String lockKey = generateLockKey(getId(), key); ReentrantLock lock = LOCAL_LOCK_MAP.get(lockKey); -- Gitee