当前位置: 首页>>代码示例>>Java>>正文


Java Jedis.zadd方法代码示例

本文整理汇总了Java中redis.clients.jedis.Jedis.zadd方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.zadd方法的具体用法?Java Jedis.zadd怎么用?Java Jedis.zadd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.zadd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pushWhenNoRepeat

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
protected void pushWhenNoRepeat(Task task, Request request) {
    Jedis jedis = jedisPool.getResource();
    try {
        String content = serializer.serialize(request);
        if(request.getPriority() == 0) {
            jedis.rpush(RedisKeys.getQueueNoPriorityKey(task), content);
        } else if (request.getPriority() > 0) {
            jedis.zadd(RedisKeys.getZsetPlusPriorityKey(task), request.getPriority(), content);
        } else {
            jedis.zadd(RedisKeys.getZsetMinusPriorityKey(task), request.getPriority(), content);
        }

        jedis.sadd(RedisKeys.getSetKey(task), request.key());
    } finally {
        jedis.close();
    }
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:19,代码来源:RedisPriorityScheduler.java

示例2: zAdd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 增加成员
 * 
 * @param key
 * @return
 */
public boolean zAdd(String key, String member, long value) {
	Jedis jedis = null;
	boolean success = true;
	boolean ret = false;
	try {
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return false;
		}
		ret = (jedis.zadd(key, value, member) > 0);
	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "zAdd key:" + key + "member:" + member + "value:" + value, e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	return ret;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:RedisService.java

示例3: zAddMap

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 增加成员
 * 
 * @return
 */
public boolean zAddMap(String key, Map<String, Double> scoreMembers) {
	Jedis jedis = null;
	boolean success = true;
	boolean ret = false;
	try {
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return false;
		}
		// 记录最后一个心跳时间
		ret = (jedis.zadd(key, scoreMembers) > 0);
	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "zAddMap key:" + key, e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	return ret;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:26,代码来源:RedisService.java

示例4: zadd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 向有序集合添加元素
 *
 * @param key key
 * @param scoreMembers Map
 * @param seconds seconds
 */
public boolean zadd(String key, Map<String, Double> scoreMembers, int seconds) {
    Jedis jedis = null;
    try {
        jedis = getConnect();
        jedis.zadd(key, scoreMembers);
        if (seconds > 0) {
            jedis.expire(key, seconds);
        }
    } catch (Exception e) {
        logger.error("redis zadd data failed!", e);
        return false;
    } finally {
        close(jedis);
    }
    return true;
}
 
开发者ID:TwoDragonLake,项目名称:tdl-seckill,代码行数:24,代码来源:RedisUtil.java

示例5: zadd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public void zadd(String key, double score, String member) {
    Jedis jedis = null;
    try {
        jedis = getJedis();
        if (jedis == null) {
            logger.error("get jedis fail");
        }
        jedis.zadd(key, score, member);
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
        }
    } finally {
        returnJedisResource(jedis);
    }
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:17,代码来源:JedisUtil.java

示例6: zAdd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void zAdd(String key, Object data, double score) {
	int tries = 0;
	boolean sucess = false;
	do {
		tries++;
		try {
			Jedis jedis = pool.getResource();
			jedis.zadd(key, score, SerializationUtil.serialize(data));
			jedis.close();
			sucess = true;
		} catch (JedisConnectionException ex) {
			log.error(RedisConstants.CONN_FAILED_RETRY_MSG + tries);
			if (tries == numRetries)
				throw ex;
		}
	} while (!sucess && tries <= numRetries);
}
 
开发者ID:ran-jit,项目名称:distributed-task-scheduler,代码行数:20,代码来源:RedisDataCache.java

示例7: zadd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public void zadd(String key, long score, String member) {
  Jedis jedis = null;
  try {
    jedis = pool.getResource();
    jedis.zadd(key, score, member);
    pool.returnResource(jedis);
  } catch (Exception e) {
    LOGGER.warn("Failed to zadd key from cache {0}:{1}:{2}", key, score, member, e);
    pool.returnBrokenResource(jedis);
    throw e;
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:13,代码来源:RedisMemcacheService.java

示例8: zadd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Long zadd(String key, double score, String member) {
    Jedis jedis = null;
    Long res = null;
    try {
        jedis = pool.getResource();
        res = jedis.zadd(key, score, member);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
开发者ID:wxiaoqi,项目名称:ace-cache,代码行数:16,代码来源:RedisServiceImpl.java


注:本文中的redis.clients.jedis.Jedis.zadd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。