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

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

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

Jedis.lpush介绍

[英]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.lpush(key, args);
 }
}.runBinary(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.lpush(key, string);
 }
}.run(key);

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

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

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

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

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

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

代码示例来源:origin: shuzheng/zheng

/**
 * lpush
 * @param key
 * @param key
 */
public synchronized static void lpush(String key, String... strings) {
  try {
    Jedis jedis = RedisUtil.getJedis();
    jedis.lpush(key, strings);
    jedis.close();
  } catch (Exception e) {
    LOGGER.error("lpush error : " + e);
  }
}

代码示例来源:origin: zendesk/maxwell

private void sendToRedis(String msg) {
  switch (redistype) {
    case "lpush":
      jedis.lpush(this.listkey, msg);
      break;
    case "pubsub":
    default:
      jedis.publish(this.channel, msg);
      break;
  }
  this.succeededMessageCount.inc();
  this.succeededMessageMeter.mark();
}

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

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

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

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

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

@Override
protected void pushWhenNoDuplicate(Request request, Task task)
{
  Jedis jedis = pool.getResource();
  try
  {
    if(request.getPriority() > 0)
      jedis.zadd(getZsetPlusPriorityKey(task), request.getPriority(), request.getUrl());
    else if(request.getPriority() < 0)
      jedis.zadd(getZsetMinusPriorityKey(task), request.getPriority(), request.getUrl());
    else
      jedis.lpush(getQueueNoPriorityKey(task), request.getUrl());
    setExtrasInItem(jedis, request, task);
  }
  finally
  {
    pool.returnResource(jedis);
  }
}

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

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

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

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

代码示例来源:origin: io.leopard/leopard-redis

@Override
  public Object execute(Jedis jedis) {
    return jedis.lpush(key, strings);
  }
});

代码示例来源:origin: techa03/goodsKill

public String put(String key, Object value) {
  Jedis jedis = jedisPool.getResource();
  try {
    jedis.lpush(key, value.toString());
  } finally {
    jedis.close();
  }
  return null;
}

代码示例来源:origin: JFanZhao/spider

public void add(String lowKey, String url){
  Jedis resource = jedisPool.getResource();
  Long lpush = resource.lpush(lowKey, url);
  jedisPool.returnResourceObject(resource);
  
}

代码示例来源:origin: liunian1004/vua

public synchronized static void lpush(String key, String... strings) {
  try {
    Jedis jedis = getJedis();
    jedis.lpush(key, strings);
    jedis.close();
  } catch (Exception e) {
    _log.error("lpush error : " + e);
  }
}

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

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

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

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

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

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

相关文章

Jedis类方法