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

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

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

Pipeline.incrBy介绍

暂无

代码示例

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

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

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

@Override
Response<Long> execute(Pipeline jedisPipeline) throws DynoException {
  return jedisPipeline.incrBy(key, integer);
}

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

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

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

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

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

public Map<String, Long> versions(String[] keys) {
  Map<String, Response<Long>> holders = new HashMap<String, Response<Long>>();
  redis.pipeline(pipe -> {
    for (String key : keys) {
      holders.put(key, pipe.incrBy(keyForVersion(key), 0));
    }
  });
  Map<String, Long> versions = new HashMap<String, Long>(keys.length);
  for (String key : keys) {
    versions.put(key, holders.get(key).get());
  }
  return versions;
}

代码示例来源: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: com.coveo/spillway

.collect(Collectors.joining(KEY_SEPARATOR));
responses.put(limitKey, pipeline.incrBy(redisKey, request.getCost()));

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

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

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

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

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

public ServiceSet serviceSet(String name) {
  Holder<Response<Long>> version = new Holder<Response<Long>>();
  Holder<Response<Set<Tuple>>> services = new Holder<Response<Set<Tuple>>>();
  Holder<Response<Map<String, String>>> payloadsHolder = new Holder<Response<Map<String, String>>>();
  this.redis.pipeline(pipe -> {
    version.set(pipe.incrBy(keyForVersion(name), 0));
    services.set(pipe.zrangeWithScores(keyForSet(name), 0, -1));
    payloadsHolder.set(pipe.hgetAll(keyForPayload(name)));
  });
  Set<ServiceItem> items = new HashSet<ServiceItem>();
  long now = System.currentTimeMillis() / 1000;
  Map<String, String> payloads = payloadsHolder.value().get();
  for (Tuple tuple : services.value().get()) {
    String[] pair = tuple.getElement().split(":");
    String host = pair[0];
    int port = Integer.parseInt(pair[1]);
    int ttl = (int) (tuple.getScore() - now);
    String payload = payloads.get(tuple.getElement());
    items.add(new ServiceItem(name, host, port, ttl, payload));
  }
  ServiceSet set = new ServiceSet(name, items, version.value().get());
  if (set.isEmpty()) {
    this.redis.execute(jedis -> {
      jedis.srem(nameKeys, name);
    });
  }
  return set;
}

代码示例来源: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类方法