@@ -89,7 +89,7 @@ protected void reloadCache() {
8989 }
9090
9191 cacheRef .set (newCache );
92- LOG .info ("----- Redis all cacheRef reload end:{}" , Calendar . getInstance ());
92+ LOG .info ("----- Redis all cacheRef reload end:{}" , newCache . size ());
9393 }
9494
9595 @ Override
@@ -142,16 +142,18 @@ private String buildCacheKey(Map<String, String> refData) {
142142 private void loadData (Map <String , Map <String , String >> tmpCache ) throws SQLException {
143143 JedisCommands jedis = null ;
144144 try {
145- String keyPattern = tableInfo .getTableName () + "*" ;
145+ StringBuilder keyPattern = new StringBuilder (tableInfo .getTableName ());
146+ for (String key : tableInfo .getPrimaryKeys ()){
147+ keyPattern .append ("_" ).append ("*" );
148+ };
146149 jedis = getJedisWithRetry (CONN_RETRY_NUM );
147- Set <String > keys = getRedisKeys (RedisType .parse (tableInfo .getRedisType ()), jedis , keyPattern );
150+ Set <String > keys = getRedisKeys (RedisType .parse (tableInfo .getRedisType ()), jedis , keyPattern . toString () );
148151 if (CollectionUtils .isEmpty (keys )){
149152 return ;
150153 }
151- JedisCommands redis = jedis ;
152- keys .forEach (k ->{
153- tmpCache .put (k , redis .hgetAll (k ));
154- });
154+ for (String key : keys ){
155+ tmpCache .put (key , jedis .hgetAll (key ));
156+ }
155157 } catch (Exception e ){
156158 LOG .error ("" , e );
157159 } finally {
@@ -174,7 +176,7 @@ private void loadData(Map<String, Map<String, String>> tmpCache) throws SQLExcep
174176 private JedisCommands getJedis (RedisSideTableInfo tableInfo ) {
175177 String url = tableInfo .getUrl ();
176178 String password = tableInfo .getPassword ();
177- String database = tableInfo .getDatabase ();
179+ String database = tableInfo .getDatabase () == null ? "0" : tableInfo . getDatabase () ;
178180 int timeout = tableInfo .getTimeout ();
179181 if (timeout == 0 ){
180182 timeout = 1000 ;
0 commit comments