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

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

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

Jedis.spop介绍

[英]Remove a random element from a Set returning it as return value. If the Set is empty or the key does not exist, a nil object is returned.

The #srandmember(String) command does a similar work but the returned element is not removed from the Set.

Time complexity O(1)
[中]从将其作为返回值返回的集合中移除随机元素。如果集合为空或键不存在,则返回nil对象。
#srandmember(String)命令执行类似的工作,但返回的元素不会从集合中删除。
时间复杂度O(1)

代码示例

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

@Override
 public byte[] execute(Jedis connection) {
  return connection.spop(key);
 }
}.runBinary(key);

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

@Override
 public Set<String> execute(Jedis connection) {
  return connection.spop(key, count);
 }
}.run(key);

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

@Override
 public Set<byte[]> execute(Jedis connection) {
  return connection.spop(key, count);
 }
}.runBinary(key);

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

@Override
 public String execute(Jedis connection) {
  return connection.spop(key);
 }
}.run(key);

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

public byte[] execute(Jedis connection) {
    return connection.spop(keyByte);
  }
}.runBinary(keyByte);

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

@Override
public byte[] spop(byte[] key) {
 Jedis j = getShard(key);
 return j.spop(key);
}

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

@Override
public String spop(String key) {
 Jedis j = getShard(key);
 return j.spop(key);
}

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

@Override
public Set<byte[]> spop(byte[] key, long count) {
 Jedis j = getShard(key);
 return j.spop(key, count);
}

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

@Override
public Set<String> spop(String key, long count) {
 Jedis j = getShard(key);
 return j.spop(key, count);
}

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

@Override
public Set<String> spop(String key, long count) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.spop(key, count);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

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

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

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

/**
 * 移除并返回集合中的一个随机元素。
 * 如果只想获取一个随机元素,但不想该元素从集合中被移除的话,可以使用 SRANDMEMBER 命令。
 */
@SuppressWarnings("unchecked")
public <T> T spop(Object key) {
  Jedis jedis = getJedis();
  try {
    return (T)valueFromBytes(jedis.spop(keyToBytes(key)));
  }
  finally {close(jedis);}
}

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

@Override
public List<byte[]> sPop(byte[] key, long count) {
  Assert.notNull(key, "Key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().spop(key, count), ArrayList::new));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().spop(key, count), ArrayList::new));
      return null;
    }
    return new ArrayList<>(connection.getJedis().spop(key, count));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

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

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

public String spopString(String key){
  Jedis jedis = null;
  boolean sucess = true;
  String rt = null;
  try {
    jedis = jedisPool.getResource();
    rt = jedis.spop(key);
  } catch (Exception e) {
    sucess = false;
    returnBrokenResource(jedis, "spopString"+key, e);
  } finally {
    if (sucess && jedis != null) {
      returnResource(jedis);
    }
  }
  return rt;
}

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

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

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

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

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

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

代码示例来源:origin: com.github.yamingd.argo/argo-redis

public String execute(final Jedis conn) throws Exception {
    byte[] bytes = conn.spop(SafeEncoder.encode(key));
    if (bytes == null){
      return null;
    }
    return SafeEncoder.encode(bytes);
  }
});

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

@Override
public Set<String> spop(String key, long count) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.spop(key, count);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

相关文章

微信公众号

最新文章

更多

Jedis类方法