Java Code Examples for redis.clients.jedis.Jedis#spop()

The following examples show how to use redis.clients.jedis.Jedis#spop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChurchDB.java    From VileBot with MIT License 6 votes vote down vote up
/**
 * Change the title of noun to a string.
 *
 * @param noun The noun to change the karma of
 * @param newTitle The string to change the title to
 */
public static void modDonorTitle( String noun, String newTitle )
{
    Jedis jedis = pool.getResource();
    Long titleCount = jedis.scard( keyOfChurchDonorTitleSortedSet + noun );
    try
    {
        for ( Long i = 0L; i < titleCount; i++ )
        {
            jedis.spop( keyOfChurchDonorTitleSortedSet + noun );
        }
        jedis.sadd( keyOfChurchDonorTitleSortedSet + noun, newTitle );
    }
    finally
    {
        pool.returnResource( jedis );
    }
}
 
Example 2
Source File: RedisDataSet.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
private String getDataFromConnection(Jedis conn, String key) {
    String line = null;

    try {
        if (redisDataType == RedisDataType.REDIS_DATA_TYPE_LIST) {
            log.debug("Executing lpop against redis list");
            // Get data from list's head
            line = conn.lpop(key);
        } else if (redisDataType.equals(RedisDataType.REDIS_DATA_TYPE_SET)) {
            log.debug("Executing spop against redis set");
            line = conn.spop(key);
        } else {
            log.warn("Unexpected redis datatype: {0}".format(key));
        }
    } catch (JedisDataException jde) {
        log.error("Exception when retrieving data from Redis: " + jde);
    }

    return line;
}
 
Example 3
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * 通过key随机删除一个set中的value并返回该值
 * </p>
 *
 * @param key
 * @return
 */
public String spop(String key) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.spop(key);
    } catch (Exception e) {

        log.error(e.getMessage());
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 4
Source File: JedisUtil.java    From Project with Apache License 2.0 5 votes vote down vote up
/**
 * 从集合中删除成员
 * 
 * @param  key
 * @return 被删除的成员
 */
public String spop(String key) {
	Jedis jedis = getJedis();
	String s = jedis.spop(key);
	jedis.close();
	return s;
}
 
Example 5
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public String spop(String key) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = pool.getResource();
        res = jedis.spop(key);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 6
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private String spop0(Jedis j, String key) {
	return j.spop(key);
}
 
Example 7
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 从集合中删除成员
 * 
 * @param String
 *            key
 * @return 被删除的成员
 * */
public String spop(String key) {
	Jedis jedis = getJedis();
	String s = jedis.spop(key);
	returnJedis(jedis);
	return s;
}