美文网首页
使用Pipeline批量查询String类型的值

使用Pipeline批量查询String类型的值

作者: 马木木 | 来源:发表于2020-04-20 14:55 被阅读0次
      public static List<String> pipeLineGetStringVal2(List<String> keys,Jedis jedis) {
            List<String> dataList = new ArrayList<>();
            List<JedisDataException> errorList = new ArrayList<>();
            Pipeline pipeline = jedis.pipelined();
            for (String key : keys) {
                pipeline.get(key);
            }
            List<Object> objectList = pipeline.syncAndReturnAll();
            for (Object result : objectList) {
                if (result instanceof String) {
                    dataList.add((String) result);
                }
                if (result instanceof JedisDataException) {
                    errorList.add((JedisDataException) result);
    
                }
            }
            if (errorList.size() > 0) {
    
                logger.error("pipeLineGet(" + keys + ") error", errorList.get(0));
            }
    
            return dataList;
    
    
    
    
        }
    
    

    相关文章

      网友评论

          本文标题:使用Pipeline批量查询String类型的值

          本文链接:https://www.haomeiwen.com/subject/arkdihtx.html