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

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(156)

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

Jedis.rpush介绍

[英]Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.

Time complexity: O(1)
[中]将字符串值添加到存储在键处的列表的头部(LPUSH)或尾部(RPUSH)。如果键不存在,将在追加操作之前创建一个空列表。如果密钥存在但不是列表,则返回错误。
时间复杂度:O(1)

代码示例

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

@Override
 public Long execute(Jedis connection) {
  return connection.rpush(key, string);
 }
}.run(key);

代码示例来源:origin: caoxinyu/RedisClient

@Override
protected void command() {
  jedis.select(db);
  if (jedis.exists(key) && getValueType(key) != NodeType.LIST)
    throw new RuntimeException(RedisClient.i18nFile.getText(I18nFile.LISTEXIST) + key);
  beforeAdd();
  
  for (String value : values) {
    if (headTail && exist)
      jedis.rpush(key, value);
    else if (headTail && !exist)
      jedis.rpushx(key, value);
    else if (!headTail && exist)
      jedis.lpush(key, value);
    else
      jedis.lpushx(key, value);
  }
  afterAdd();
}

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

@Override
 public Long execute(Jedis connection) {
  return connection.rpush(key, args);
 }
}.runBinary(key);

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

public Long execute(Jedis connection) {
    return connection.rpush(keyByte, string);
  }
}.runBinary(keyByte);

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

@Override
public Long rpush(byte[] key, byte[]... strings) {
 Jedis j = getShard(key);
 return j.rpush(key, strings);
}

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

@Override
public Long rpush(String key, String... strings) {
 Jedis j = getShard(key);
 return j.rpush(key, strings);
}

代码示例来源:origin: Netflix/conductor

@Override
public Long rpush(String key, String... string) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.rpush(key, string);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

代码示例来源:origin: code4craft/webmagic

@Override
protected void pushWhenNoDuplicate(Request request, Task task) {
  Jedis jedis = pool.getResource();
  try {
    jedis.rpush(getQueueKey(task), request.getUrl());
    if (checkForAdditionalInfo(request)) {
      String field = DigestUtils.shaHex(request.getUrl());
      String value = JSON.toJSONString(request);
      jedis.hset((ITEM_PREFIX + task.getUUID()), field, value);
    }
  } finally {
    jedis.close();
  }
}

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

/**
 * 将一个或多个值 value 插入到列表 key 的表尾(最右边)。
 * 如果有多个 value 值,那么各个 value 值按从左到右的顺序依次插入到表尾:比如
 * 对一个空列表 mylist 执行 RPUSH mylist a b c ,得出的结果列表为 a b c ,
 * 等同于执行命令 RPUSH mylist a 、 RPUSH mylist b 、 RPUSH mylist c 。
 * 如果 key 不存在,一个空列表会被创建并执行 RPUSH 操作。
 * 当 key 存在但不是列表类型时,返回一个错误。
 */
public Long rpush(Object key, Object... values) {
  Jedis jedis = getJedis();
  try {
    return jedis.rpush(keyToBytes(key), valuesToBytesArray(values));
  }
  finally {close(jedis);}
}

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

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

代码示例来源:origin: spinnaker/kayenta

public void startPendingUpdate(AccountCredentials credentials, String updatedTimestamp, CanaryConfigIndexAction action, String correlationId, String canaryConfigSummaryJson) {
 String accountName = credentials.getName();
 String mapPendingUpdatesByApplicationKey = buildMapPendingUpdatesByApplicationKey(credentials, accountName);
 try (Jedis jedis = jedisPool.getResource()) {
  jedis.rpush(mapPendingUpdatesByApplicationKey, updatedTimestamp + ":" + action + ":start:" + correlationId + ":" + canaryConfigSummaryJson);
 }
}

代码示例来源:origin: jwpttcg66/NettyGameServer

public long rpush(String key, String value) {
  Jedis jedis = null;
  boolean sucess = true;
  long ret = -1;
  try {
    jedis = jedisPool.getResource();
    ret = jedis.rpush(key, value);
  } catch (Exception e) {
    sucess = false;
    returnBrokenResource(jedis, "rpush key:"+key + "value:"+ value, e);
  } finally {
    if (sucess && jedis != null) {
      returnResource(jedis);
    }
  }
  return ret;
}

代码示例来源:origin: jwpttcg66/NettyGameServer

/**返回的是列表的剩余个数*/
public long rPushString(String key,String value){
  Jedis jedis = null;
  boolean sucess = true;
  long result = 0;
  try {
    jedis = jedisPool.getResource();
    result = jedis.rpush(key, value);
  } catch (Exception e) {
    sucess = false;
    returnBrokenResource(jedis, "rpushString"+key, e);
  } finally {
    if (sucess && jedis != null) {
      returnResource(jedis);
    }
  }
  return result;
}

代码示例来源:origin: spinnaker/kayenta

public void finishPendingUpdate(AccountCredentials credentials, CanaryConfigIndexAction action, String correlationId) {
 String accountName = credentials.getName();
 String mapPendingUpdatesByApplicationKey = buildMapPendingUpdatesByApplicationKey(credentials, accountName);
 try (Jedis jedis = jedisPool.getResource()) {
  jedis.rpush(mapPendingUpdatesByApplicationKey, getRedisTime() + ":" + action + ":finish:" + correlationId);
 }
}

代码示例来源:origin: com.vlkan.log4j2/log4j2-redis-appender

void consumeThrottledEvents(byte[]... events) {
  logger.debug("consuming %d events", events.length);
  try (Jedis jedis = jedisPool.getResource()) {
    jedis.rpush(keyBytes, events);
  }
}

代码示例来源:origin: com.wso2telco.core/pcr-service

@Override
public void createNewPCRMSISDNEntry(String userId, String sectorId, String pcr) throws PCRException {
  Jedis jedis= RedisUtil.getInstance().getResource();
  jedis.rpush(sectorId + ":" + pcr,userId);
  jedis.close();
}

代码示例来源:origin: com.netflix.kayenta/kayenta-core

public void startPendingUpdate(AccountCredentials credentials, String updatedTimestamp, CanaryConfigIndexAction action, String correlationId, String canaryConfigSummaryJson) {
 String accountName = credentials.getName();
 String mapPendingUpdatesByApplicationKey = buildMapPendingUpdatesByApplicationKey(credentials, accountName);
 try (Jedis jedis = jedisPool.getResource()) {
  jedis.rpush(mapPendingUpdatesByApplicationKey, updatedTimestamp + ":" + action + ":start:" + correlationId + ":" + canaryConfigSummaryJson);
 }
}

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

@Override
public Long rpush(String key, String... strings) {
 String command = "rpush";
 return instrumented(command, payloadSize(strings), () -> delegated.rpush(key, strings));
}

代码示例来源:origin: com.netflix.kayenta/kayenta-core

public void finishPendingUpdate(AccountCredentials credentials, CanaryConfigIndexAction action, String correlationId) {
 String accountName = credentials.getName();
 String mapPendingUpdatesByApplicationKey = buildMapPendingUpdatesByApplicationKey(credentials, accountName);
 try (Jedis jedis = jedisPool.getResource()) {
  jedis.rpush(mapPendingUpdatesByApplicationKey, getRedisTime() + ":" + action + ":finish:" + correlationId);
 }
}

代码示例来源:origin: com.wso2telco.core/pcr-service

@Override
public void createNewPcrEntry(RequestDTO requestDTO, String pcr) throws PCRException {
  Jedis jedis = RedisUtil.getInstance().getResource();
  jedis.rpush(requestDTO.getUserId() + ":" + requestDTO.getSectorId(), requestDTO.getAppId() + ":" + pcr);
  jedis.close();
}

相关文章

微信公众号

最新文章

更多

Jedis类方法