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

The following examples show how to use redis.clients.jedis.Jedis#zscore() . 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: RedisJobStore.java    From redis-quartz with MIT License 6 votes vote down vote up
/**
 * Resume a trigger in redis.
 *
 * @param trigger the trigger
 * @param jedis thread-safe redis connection
 * @throws JobPersistenceException
 */
private void resumeTrigger(OperableTrigger trigger, Jedis jedis) throws JobPersistenceException {
	String triggerHashKey = createTriggerHashKey(trigger.getKey().getGroup(), trigger.getKey().getName());
	if (!jedis.sismember(TRIGGERS_SET, triggerHashKey))
		throw new JobPersistenceException("trigger: " + trigger + " does not exist");
	
	if (jedis.zscore(RedisTriggerState.PAUSED.getKey(), triggerHashKey) == null && jedis.zscore(RedisTriggerState.PAUSED_BLOCKED.getKey(), triggerHashKey) == null)
		throw new JobPersistenceException("trigger: " + trigger + " is not paused");
			
	String jobHashKey = createJobHashKey(trigger.getJobKey().getGroup(), trigger.getJobKey().getName());
	Date nextFireTime = trigger.getNextFireTime();
	if (nextFireTime != null) {
		if (jedis.sismember(BLOCKED_JOBS_SET, jobHashKey))
			setTriggerState(RedisTriggerState.BLOCKED, (double)nextFireTime.getTime(), triggerHashKey);
		else
			setTriggerState(RedisTriggerState.WAITING, (double)nextFireTime.getTime(), triggerHashKey);
	}
}
 
Example 2
Source File: KarmaDB.java    From VileBot with MIT License 6 votes vote down vote up
/**
 * Get the karma of a noun.
 * 
 * @param noun The noun to query to karma of
 * @return Integer iff the noun has a defined value, else null
 */
public static Integer getNounKarma( String noun )
{
    Jedis jedis = pool.getResource();
    Double karma;
    try
    {
        karma = jedis.zscore( keyOfKarmaSortedSet, noun );
    }
    finally
    {
        pool.returnResource( jedis );
    }

    if ( karma == null )
    {
        return null;
    }

    return Integer.valueOf( Long.valueOf( Math.round( karma ) ).intValue() );
}
 
Example 3
Source File: ChurchDB.java    From VileBot with MIT License 6 votes vote down vote up
/**
 * Get the karma of a noun.
 *
 * @param noun The noun to query to karma of
 * @return Integer iff the noun has a defined value, else null
 */
public static Integer getDonorKarma( String noun )
{
    Jedis jedis = pool.getResource();
    Double karma;
    try
    {
        karma = jedis.zscore( keyOfChurchDonorSortedSet, noun );
    }
    finally
    {
        pool.returnResource( jedis );
    }
    if ( karma == null )
    {
        return null;
    }

    return Long.valueOf( Math.round( karma ) ).intValue();
}
 
Example 4
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * 通过key获取zset中value的score值
 * </p>
 *
 * @param key
 * @param member
 * @return
 */
public Double zscore(String key, String member) {
    Jedis jedis = null;
    Double res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.zscore(key, member);
    } catch (Exception e) {

        log.error(e.getMessage());
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 5
Source File: JedisUtil.java    From scaffold-cloud with MIT License 5 votes vote down vote up
/**
 * 获取sortedset中的列表的成员的分值
 *
 * @param key
 * @param member
 * @return
 */
public static Double zscore(String key, String member) {
    Double result = null;
    Jedis jedis = null;
    try {
        jedis = getResource();
        result = jedis.zscore(key, member);
    } catch (Exception e) {
        logger.warn("zscore {} = {}", key, member, e);
    } finally {
        close(jedis);
    }
    return result;
}
 
Example 6
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public Double zscore(String key, String member) {
    Jedis jedis = null;
    Double res = null;
    try {
        jedis = pool.getResource();
        res = jedis.zscore(key, member);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 7
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 获取给定值在集合中的权重
 * 
 * @param String
 *            key
 * @param memeber
 * @return double 权重
 * */
public double zscore(String key, String memebr) {
	// ShardedJedis sjedis = getShardedJedis();
	Jedis sjedis = getJedis();
	Double score = sjedis.zscore(key, memebr);
	returnJedis(sjedis);
	if (score != null)
		return score;
	return 0;
}
 
Example 8
Source File: RedisJobStore.java    From redis-quartz with MIT License 5 votes vote down vote up
/**
 * Pause trigger in redis.
 *
 * @param triggerKey the trigger key
 * @param jedis thread-safe redis connection
 * @throws JobPersistenceException
 */
private void pauseTrigger(TriggerKey triggerKey, Jedis jedis) throws JobPersistenceException {
	String triggerHashKey = createTriggerHashKey(triggerKey.getGroup(), triggerKey.getName());
	if (!jedis.exists(triggerHashKey))
		throw new JobPersistenceException("trigger: " + triggerHashKey + " does not exist");
			
	if (jedis.zscore(RedisTriggerState.COMPLETED.getKey(), triggerHashKey) != null)
		return;
	
	Long nextFireTime = jedis.hget(triggerHashKey, NEXT_FIRE_TIME).isEmpty() ? -1 : Long.parseLong(jedis.hget(triggerHashKey, NEXT_FIRE_TIME));
	if (jedis.zscore(RedisTriggerState.BLOCKED.getKey(), triggerHashKey) != null)
		setTriggerState(RedisTriggerState.PAUSED_BLOCKED, (double)nextFireTime, triggerHashKey);
	else
		setTriggerState(RedisTriggerState.PAUSED, (double)nextFireTime, triggerHashKey);		
}
 
Example 9
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Double zscore0(Jedis j, String key, String member) {
	return j.zscore(key, member);
}