redis.clients.jedis.Pipeline.exec()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(420)

本文整理了Java中redis.clients.jedis.Pipeline.exec()方法的一些代码示例,展示了Pipeline.exec()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pipeline.exec()方法的具体详情如下:
包路径:redis.clients.jedis.Pipeline
类名称:Pipeline
方法名:exec

Pipeline.exec介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public List<Object> exec() {
  try {
    if (isPipelined()) {
      pipeline(newJedisResult(getRequiredPipeline().exec(),
          new TransactionResultConverter<>(new LinkedList<>(txResults), JedisConverters.exceptionConverter())));
      return null;
    }
    if (transaction == null) {
      throw new InvalidDataAccessApiUsageException("No ongoing transaction. Did you forget to call multi?");
    }
    List<Object> results = transaction.exec();
    return !CollectionUtils.isEmpty(results)
        ? new TransactionResultConverter<>(txResults, JedisConverters.exceptionConverter()).convert(results)
        : results;
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  } finally {
    txResults.clear();
    transaction = null;
  }
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Response<List<Object>> exec() {
 String command = "exec";
 return instrumented(command, () -> delegated.exec());
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-redis

@FinishBundle
public void finishBundle() {
 if (pipeline.isInMulti()) {
  pipeline.exec();
 }
 batchCount = 0;
}

代码示例来源:origin: pyloque/captain

public void pipeline(Consumer<Pipeline> func) {
  try (Jedis jedis = pool.getResource()) {
    try (Pipeline pipe = jedis.pipelined()) {
      pipe.multi();
      func.accept(pipe);
      pipe.exec();
    } catch (IOException e) {
      throw new RuntimeException("pipe close error", e);
    }
  }
}

代码示例来源:origin: com.github.yamingd.argo/argo-redis

public Long execute(final Jedis conn) throws Exception {
    Pipeline pipe = conn.pipelined();
    byte[] bk = SafeEncoder.encode(key);
    for(String field : nums.keySet()){
      pipe.hincrBy(bk, SafeEncoder.encode(field), nums.get(field));
    }
    pipe.exec();
    return 1L;
  }
});

代码示例来源:origin: com.github.yamingd.argo/argo-redis

public Long execute(final Jedis conn) throws Exception {
    byte[] bk = SafeEncoder.encode(key);
    Pipeline pipe = conn.pipelined();
    for(String field : nums.keySet()){
      pipe.hincrBy(bk, SafeEncoder.encode(field), -1 * nums.get(field));
    }
    pipe.exec();
    return 1L;
  }
});

代码示例来源:origin: com.github.yamingd.argo/argo-redis

public Long execute(final Jedis conn) throws Exception {
    byte[] bk = SafeEncoder.encode(key);
    Pipeline pipe = conn.pipelined();
    for(String field : nums.keySet()){
      pipe.hset(bk, SafeEncoder.encode(field), SafeEncoder.encode(String.valueOf(nums.get(field))));
    }
    pipe.exec();
    return 1L;
  }
});

代码示例来源:origin: intsmaze/intsmaze

@Test
public void testPipelineTrans() {
  long start = System.currentTimeMillis();
  Pipeline pipeline = jedis.pipelined();
  pipeline.multi();
  for (int i = 0; i < 100000; i++) {
    pipeline.set("" + i, "" + i);
  }
  pipeline.exec();
  List<Object> results = pipeline.syncAndReturnAll();
  long end = System.currentTimeMillis();
  System.out.println("Pipelined transaction SET: " + ((end - start)/1000.0) + " seconds");
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-redis

@ProcessElement
public void processElement(ProcessContext processContext) {
 KV<String, String> record = processContext.element();
 writeRecord(record);
 batchCount++;
 if (batchCount >= DEFAULT_BATCH_SIZE) {
  pipeline.exec();
  pipeline.multi();
  batchCount = 0;
 }
}

代码示例来源:origin: gojektech/feast

private void exec() {
 // LOGGER.info("Flushing pipeline");
 if (!pipeline.isInMulti()) {
  pipeline.multi();
 }
 pipeline.exec();
 pipeline.multi();
 batchCount = 0;
}

代码示例来源:origin: com.github.yamingd.argo/argo-redis

public Long execute(final Jedis conn) throws Exception {
    byte[] bk = SafeEncoder.encode(key);
    Pipeline pipe = conn.pipelined();
    for(Object v : members){
      pipe.sadd(bk, SafeEncoder.encode(String.valueOf(v)));
    }
    pipe.exec();
    return 1L;
  }
});

代码示例来源:origin: kstyrc/trident-redis

public void multiPut(List<List<Object>> keys, List<T> vals) {
 if (keys.size() == 0) {
   return;
 }
 if (Strings.isNullOrEmpty(this.options.hkey)) {
   String[] keyValues = buildKeyValuesList(keys, vals);
   mset(keyValues);
 } else {
   Jedis jedis = pool.getResource();
   try {
    Pipeline pl = jedis.pipelined();
    pl.multi();
    for (int i = 0; i < keys.size(); i++) {
      String val = new String(serializer.serialize(vals.get(i)));
      pl.hset(this.options.hkey,
         keyFactory.build(keys.get(i)),
         val);
    }
    pl.exec();
    pl.sync();
   } finally {
    pool.returnResource(jedis);
   }
 }
}

代码示例来源:origin: com.coveo/spillway

pipeline.exec();

代码示例来源:origin: Baqend/Orestes-Bloomfilter

@SuppressWarnings("unchecked")
public <T> List<T> transactionallyDo(Consumer<Pipeline> f, String... watch) {
  return (List<T>) safelyReturn(jedis -> {
    Pipeline p = jedis.pipelined();
    if (watch.length != 0) {
      p.watch(watch);
    }
    p.multi();
    f.accept(p);
    Response<List<Object>> exec = p.exec();
    p.sync();
    return exec.get();
  });
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public List<Object> exec() {
  try {
    if (isPipelined()) {
      pipeline(newJedisResult(getRequiredPipeline().exec(),
          new TransactionResultConverter<>(new LinkedList<>(txResults), JedisConverters.exceptionConverter())));
      return null;
    }
    if (transaction == null) {
      throw new InvalidDataAccessApiUsageException("No ongoing transaction. Did you forget to call multi?");
    }
    List<Object> results = transaction.exec();
    return !CollectionUtils.isEmpty(results)
        ? new TransactionResultConverter<>(txResults, JedisConverters.exceptionConverter()).convert(results)
        : results;
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  } finally {
    txResults.clear();
    transaction = null;
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public List<Object> exec() {
  try {
    if (isPipelined()) {
      pipeline(newJedisResult(getRequiredPipeline().exec(),
          new TransactionResultConverter<>(new LinkedList<>(txResults), JedisConverters.exceptionConverter())));
      return null;
    }
    if (transaction == null) {
      throw new InvalidDataAccessApiUsageException("No ongoing transaction. Did you forget to call multi?");
    }
    List<Object> results = transaction.exec();
    return !CollectionUtils.isEmpty(results)
        ? new TransactionResultConverter<>(txResults, JedisConverters.exceptionConverter()).convert(results)
        : results;
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  } finally {
    txResults.clear();
    transaction = null;
  }
}

代码示例来源:origin: Baqend/Orestes-Bloomfilter

p.multi();
p.set("muh", "mäh");
p.exec();
p.sync();
System.out.println(jedis.get("muh"));
pipe.multi();
pipe.set("myKey", "myVal");
Response<List<Object>> result = pipe.exec();
pipe.sync();
for (Object o : result.get())

代码示例来源:origin: Baqend/Orestes-Bloomfilter

@Ignore
@Test
public void testOverflow() {
  Jedis jedis = new Jedis("localhost");
  Pipeline p = jedis.pipelined();
  p.multi();
  for (int i = 0; i < 10000; i++) {
    p.setbit("test", 1, true); //or any other call
  }
  Response<List<Object>> exec = p.exec();
  p.sync();
  exec.get();
}

相关文章

Pipeline类方法