From 37689f7253d614fcaaa9f7d22e0f1c9176c7a1c7 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 2 Jan 2021 12:30:56 +0800 Subject: [PATCH] =?UTF-8?q?[Update][Fix]=20CacheStore-Redis=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=BB=86=E8=8A=82,=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20RedisMap=20=E4=B8=AD=20'putAll()'=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E9=9D=9E=E7=A9=BA=E6=A3=80=E6=9F=A5=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=8F=91=E7=94=9F=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Update] RedisMapCacheStoreTest 增加对 'putAll()' 参数传递空 Map 的测试; [Fix] RedisMapCacheStore 修复因条件错误导致未能准确排除空 Map 的问题; --- .../java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStore.java | 2 +- .../net/lamgc/cgj/bot/cache/redis/RedisMapCacheStoreTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStore.java b/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStore.java index e694b8f..6de0d2b 100644 --- a/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStore.java +++ b/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStore.java @@ -110,7 +110,7 @@ public class RedisMapCacheStore extends RedisCacheStore> imple public boolean putAll(CacheKey key, Map map) { Objects.requireNonNull(key); Objects.requireNonNull(map); - if (map.size() == 0 && exists(key)) { + if (map.size() == 0) { return true; } diff --git a/ContentGrabbingJi-CacheStore-redis/src/test/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStoreTest.java b/ContentGrabbingJi-CacheStore-redis/src/test/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStoreTest.java index 863c7ad..ef6c6f6 100644 --- a/ContentGrabbingJi-CacheStore-redis/src/test/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStoreTest.java +++ b/ContentGrabbingJi-CacheStore-redis/src/test/java/net/lamgc/cgj/bot/cache/redis/RedisMapCacheStoreTest.java @@ -135,6 +135,9 @@ public class RedisMapCacheStoreTest { Assert.assertTrue("clearMap operation failed!", cacheStore.clearMap(key)); // putAll + // empty map + Assert.assertTrue(cacheStore.putAll(key, new HashMap<>())); + // non-empty map Assert.assertTrue(cacheStore.putAll(key, expectedMap)); Assert.assertTrue(expectedMap.keySet().containsAll(cacheStore.mapFieldSet(key))); Assert.assertTrue(expectedMap.values().containsAll(cacheStore.mapValueSet(key)));