diff --git a/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisConnectionPool.java b/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisConnectionPool.java index 1ad0abb..1ac0a64 100644 --- a/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisConnectionPool.java +++ b/ContentGrabbingJi-CacheStore-redis/src/main/java/net/lamgc/cgj/bot/cache/redis/RedisConnectionPool.java @@ -85,6 +85,7 @@ class RedisConnectionPool { JedisPool jedisPool = POOL.get(); if (jedisPool == null || jedisPool.isClosed()) { reconnectRedis(); + jedisPool = POOL.get(); if (jedisPool == null || jedisPool.isClosed()) { return false; } diff --git a/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java b/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java index 5d431f1..a19aa9f 100644 --- a/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java +++ b/ContentGrabbingJi-core/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java @@ -112,6 +112,8 @@ public class CacheStoreBuilder { try { if (factory.canGetCacheStore()) { log.debug("CacheStoreFactory {} 可用(优先级: {}).", info.getFactoryName(), info.getFactoryPriority()); + } else { + continue; } } catch (Exception e) { log.error("CacheStoreFactory " + info.getFactoryName() + diff --git a/ContentGrabbingJi-core/src/test/java/net/lamgc/cgj/bot/cache/CacheStoreBuilderTest.java b/ContentGrabbingJi-core/src/test/java/net/lamgc/cgj/bot/cache/CacheStoreBuilderTest.java index 4106cdd..509efe9 100644 --- a/ContentGrabbingJi-core/src/test/java/net/lamgc/cgj/bot/cache/CacheStoreBuilderTest.java +++ b/ContentGrabbingJi-core/src/test/java/net/lamgc/cgj/bot/cache/CacheStoreBuilderTest.java @@ -19,6 +19,10 @@ package net.lamgc.cgj.bot.cache; import net.lamgc.cgj.bot.cache.convert.StringConverter; import net.lamgc.cgj.bot.cache.convert.StringToStringConverter; +import net.lamgc.cgj.bot.cache.local.CopyOnWriteArrayListCacheStore; +import net.lamgc.cgj.bot.cache.local.HashSetCacheStore; +import net.lamgc.cgj.bot.cache.redis.RedisMapCacheStore; +import net.lamgc.cgj.bot.cache.redis.RedisSingleCacheStore; import org.junit.Assert; import org.junit.Test; @@ -32,10 +36,21 @@ public class CacheStoreBuilderTest { final String identify = "test"; final StringConverter converter = new StringToStringConverter(); - Assert.assertNotNull(CacheStoreBuilder.newSingleCacheStore(CacheStoreSource.REMOTE, identify, converter)); - Assert.assertNotNull(CacheStoreBuilder.newListCacheStore(CacheStoreSource.MEMORY, identify, converter)); - Assert.assertNotNull(CacheStoreBuilder.newMapCacheStore(CacheStoreSource.REMOTE, identify, converter)); - Assert.assertNotNull(CacheStoreBuilder.newSetCacheStore(identify, converter)); + SingleCacheStore singleCacheStore = CacheStoreBuilder.newSingleCacheStore(CacheStoreSource.REMOTE, identify, converter); + Assert.assertNotNull(singleCacheStore); + Assert.assertEquals(RedisSingleCacheStore.class, singleCacheStore.getClass()); + + ListCacheStore listCacheStore = CacheStoreBuilder.newListCacheStore(CacheStoreSource.MEMORY, identify, converter); + Assert.assertNotNull(listCacheStore); + Assert.assertEquals(CopyOnWriteArrayListCacheStore.class, listCacheStore.getClass()); + + MapCacheStore mapCacheStore = CacheStoreBuilder.newMapCacheStore(CacheStoreSource.REMOTE, identify, converter); + Assert.assertNotNull(mapCacheStore); + Assert.assertEquals(RedisMapCacheStore.class, mapCacheStore.getClass()); + + SetCacheStore setCacheStore = CacheStoreBuilder.newSetCacheStore(identify, converter); + Assert.assertNotNull(setCacheStore); + Assert.assertEquals(HashSetCacheStore.class, setCacheStore.getClass()); }