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

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

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

Jedis.lrem介绍

[英]Remove the first count occurrences of the value element from the list. If count is zero all the elements are removed. If count is negative elements are removed from tail to head, instead to go from head to tail that is the normal behaviour. So for example LREM with count -2 and hello as value to remove against the list (a,b,c,hello,x,hello,hello) will leave the list (a,b,c,hello,x). The number of removed elements is returned as an integer, see below for more information about the returned value. Note that non existing keys are considered like empty lists by LREM, so LREM against non existing keys will always return 0.

Time complexity: O(N) (with N being the length of the list)
[中]从列表中删除value元素的首次计数。如果计数为零,则删除所有元素。如果计数为负值,则将元素从尾部移到头部,而不是从头部移到尾部,这是正常行为。因此,例如,将count-2和hello作为要针对列表(a,b,c,hello,x,hello,hello)移除的值的LREM将离开列表(a,b,c,hello,x)。删除的元素数以整数形式返回,有关返回值的更多信息,请参阅下文。请注意,LREM将不存在的键视为空列表,因此针对不存在键的LREM将始终返回0。
时间复杂度:O(N)(N为列表的长度)

代码示例

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

@Override
 public Long execute(Jedis connection) {
  return connection.lrem(key, count, value);
 }
}.runBinary(key);

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

@Override
 public Long execute(Jedis connection) {
  return connection.lrem(key, count, value);
 }
}.run(key);

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

public Long execute(Jedis connection) {
    return connection.lrem(keyByte, count, value);
  }
}.runBinary(keyByte);

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

@Override
public Long lrem(String key, long count, String value) {
 Jedis j = getShard(key);
 return j.lrem(key, count, value);
}

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

@Override
public Long lrem(byte[] key, long count, byte[] value) {
 Jedis j = getShard(key);
 return j.lrem(key, count, value);
}

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

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

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

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

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

/**
 * 根据参数 count 的值,移除列表中与参数 value 相等的元素。
 * count 的值可以是以下几种:
 * count > 0 : 从表头开始向表尾搜索,移除与 value 相等的元素,数量为 count 。
 * count < 0 : 从表尾开始向表头搜索,移除与 value 相等的元素,数量为 count 的绝对值。
 * count = 0 : 移除表中所有与 value 相等的值。
 */
public Long lrem(Object key, long count, Object value) {
  Jedis jedis = getJedis();
  try {
    return jedis.lrem(keyToBytes(key), count, valueToBytes(value));
  }
  finally {close(jedis);}
}

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

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

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

public void removeFailedPendingUpdate(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.lrem(mapPendingUpdatesByApplicationKey, 1, updatedTimestamp + ":" + action + ":start:" + correlationId + ":" + canaryConfigSummaryJson);
 }
}

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

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

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

jedis.lrem(pendingUpdatesKey, 1, updateToFlush);

代码示例来源:origin: yrain/smart-cache

@Override
  Long doInJedis(Jedis jedis) {
    return jedis.lrem(key, count, value);
  }
});

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

@Override
 public Long execute(Jedis connection) {
  return connection.lrem(key, count, value);
 }
}.run(key);

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

@Override
 public Long execute(Jedis connection) {
  return connection.lrem(key, count, value);
 }
}.runBinary(key);

代码示例来源:origin: gresrun/jesque

/**
   * {@inheritDoc}
   */
  @Override
  public Void doWork(final Jedis jedis) throws Exception {
    final String failedKey = key(FAILED);
    final String randId = UUID.randomUUID().toString();
    jedis.lset(failedKey, index, randId);
    jedis.lrem(failedKey, 1, randId);
    return null;
  }
});

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

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

代码示例来源:origin: xetorthio/rmq

public Long lrem(int count, String value) {
  Jedis jedis = getResource();
  Long lrem = jedis.lrem(key(), count, value);
  returnResource(jedis);
  return lrem;
}

代码示例来源:origin: vakinge/jeesuite-libs

@Override
public void unlock() { 
  if(client == null)throw new LockException("cant't unlock,because Lock not found");
  try {	
    client.lrem(lockName, 1, eventId);
    coordinator.notifyNext(client,lockName);
  } finally {
    if(client != null)coordinator.release(client);
  }
}

代码示例来源:origin: xetorthio/johm

public Long lrem(int count, String value) {
  Jedis jedis = getResource();
  Long lrem = jedis.lrem(key(), count, value);
  returnResource(jedis);
  return lrem;
}

相关文章

Jedis类方法