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

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

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

Pipeline.get介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
public void pipelineCommand(Pipeline pipeline, List<String> pipelineKeys) {
  for (String key : pipelineKeys) {
    pipeline.get(key);
  }
}

代码示例来源:origin: tonivade/claudb

p.exists("a");
p.exists("b");
p.get("a");
p.get("b");
p.getSet("a", "2");
p.get("a");
p.del("a");
p.get("a");

代码示例来源:origin: sohutv/cachecloud

@Override
public void pipelineCommand(Pipeline pipeline, List<String> pipelineKeys) {
  for (String key : pipelineKeys) {
    pipeline.get(SafeEncoder.encode(key));
  }
}

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

@Override
public byte[] get(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().get(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().get(key)));
      return null;
    }
    return connection.getJedis().get(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

@Override
public Response<byte[]> get(byte[] key) {
 String command = "get";
 return instrumented(command, () -> delegated.get(key));
}

代码示例来源:origin: stackoverflow.com

List<Response> responses = new ArrayList<>();

Pipeline p = jedis.pipelined();
for (int id: ids) {
records.add(p.get(id));
}
p.sync();

for(Reponse response : responses){
Object o = response.get();
}

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

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

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

@Override
  Response<byte[]> execute(Pipeline jedisPipeline) throws DynoException {
    long startTime = System.nanoTime() / 1000;
    try {
      return jedisPipeline.get(key);
    } finally {
      long duration = System.nanoTime() / 1000 - startTime;
      opMonitor.recordSendLatency(OpName.GET.name(), duration, TimeUnit.MICROSECONDS);
    }
  }
}.execute(key, OpName.GET);

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

@Override
  Response<String> execute(Pipeline jedisPipeline) throws DynoException {
    long startTime = System.nanoTime() / 1000;
    try {
      return jedisPipeline.get(key);
    } finally {
      long duration = System.nanoTime() / 1000 - startTime;
      opMonitor.recordSendLatency(OpName.GET.name(), duration, TimeUnit.MICROSECONDS);
    }
  }
}.execute(key, OpName.GET);

代码示例来源:origin: CodisLabs/nedis

private void testPipeline(byte[] key, byte[] value) {
  while (!stop.get()) {
    try (Jedis jedis = pool.getResource()) {
      Pipeline p = jedis.pipelined();
      for (int i = 0; i < pipeline / 2; i++) {
        p.set(key, value);
        p.get(key);
      }
      p.sync();
      reqCount.addAndGet(pipeline);
    }
  }
}

代码示例来源:origin: biezhi/java-library-examples

public static void main(String[] args) {
  try (Jedis jedis = JedisUtil.getInstance().getJedis()) {
    long start = System.currentTimeMillis();
    jedis.flushDB();
    Pipeline p = jedis.pipelined();
    for (int i = 0; i < 10000; i++) {
      p.set("age2" + i, i + "");
      System.out.println(p.get("age2" + i));
    }
    p.sync();// 这段代码获取所有的response
    long end = System.currentTimeMillis();
    System.out.println("use pipeline cost:" + (end - start) + "ms");
  }
}

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

public Map<String, KvItem> multiGet(String[] keys) {
    Map<String, Response<Long>> versions = new HashMap<String, Response<Long>>();
    Map<String, Response<String>> values = new HashMap<String, Response<String>>();
    redis.pipeline(pipe -> {
      for (String key : keys) {
        values.put(key, pipe.get(keyForItem(key)));
        versions.put(key, pipe.incrBy(keyForVersion(key), 0));
      }
    });
    Map<String, KvItem> items = new HashMap<String, KvItem>(keys.length);
    for (String key : keys) {
      KvItem item = new KvItem();
      item.setKey(key);
      String js = values.get(key).get();
      if (js != null) {
        item.setValue(new JSONObject(js));
      } else {
        item.setValue(new JSONObject());
      }
      long version = versions.get(key).get();
      item.setVersion(version);
      items.put(key, item);
    }
    return items;
  }
}

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

@Override
public byte[] get(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().get(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().get(key)));
      return null;
    }
    return connection.getJedis().get(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

@Override
public byte[] get(byte[] key) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().get(key)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().get(key)));
      return null;
    }
    return connection.getJedis().get(key);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

public KvItem get(String key) {
  Holder<Response<String>> js = new Holder<Response<String>>();
  Holder<Response<Long>> version = new Holder<Response<Long>>();
  redis.pipeline(pipe -> {
    js.set(pipe.get(keyForItem(key)));
    version.set(pipe.incrBy(keyForVersion(key), 0));
  });
  KvItem item = new KvItem();
  item.setKey(key);
  item.setVersion(version.value().get());
  if (js.value().get() != null) {
    item.setValue(new JSONObject(js.value().get()));
  } else {
    item.setValue(new JSONObject());
  }
  return item;
}

相关文章

Pipeline类方法