作者 crossoverJie

:bug: Fixing a bug.修复一个redis连接的bug

... ... @@ -103,6 +103,7 @@ public class AccountServiceRedisImpl implements AccountService {
Map<Long, CIMServerResVO> routes = new HashMap<>(64);
RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
ScanOptions options = ScanOptions.scanOptions()
.match(ROUTE_PREFIX + "*")
... ... @@ -116,6 +117,11 @@ public class AccountServiceRedisImpl implements AccountService {
parseServerInfo(routes, key);
}
try {
scan.close();
} catch (IOException e) {
LOGGER.error("IOException",e);
}
return routes;
}
... ...
... ... @@ -13,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@SpringBootTest(classes = RouteApplication.class)
@RunWith(SpringRunner.class)
... ... @@ -25,8 +26,12 @@ public class AccountServiceRedisImplTest {
@Test
public void loadRouteRelated() throws Exception {
for (int i = 0; i < 100; i++) {
Map<Long, CIMServerResVO> longCIMServerResVOMap = accountService.loadRouteRelated();
LOGGER.info("longCIMServerResVOMap={}" , JSON.toJSONString(longCIMServerResVOMap));
LOGGER.info("longCIMServerResVOMap={},cun={}" , JSON.toJSONString(longCIMServerResVOMap),i);
}
TimeUnit.SECONDS.sleep(10);
}
}
\ No newline at end of file
... ...