本文整理汇总了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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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;
}