本文整理汇总了Java中redis.clients.jedis.Transaction.zrem方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.zrem方法的具体用法?Java Transaction.zrem怎么用?Java Transaction.zrem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Transaction
的用法示例。
在下文中一共展示了Transaction.zrem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateQueuedJob
import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public synchronized void updateQueuedJob(int jobId, JSONObject newJob) {
try (Jedis jedis = jedisPool.getResource()) {
jedis.select(redisDBIndex);
if (jedis.zcard(queue) > 0) {
Optional<Double> score = null;
Set<Tuple> tuples = jedis.zrangeByScoreWithScores(queue, 0, Double.MAX_VALUE);
String old = null;
for(Tuple data : tuples) {
JSONObject detail = JSONObject.parseObject(data.getElement());
int id = detail.getIntValue(ScheduledConstants.JOB_ID);
if(id == jobId) {
score = Optional.ofNullable(data.getScore());
old = data.getElement();
break;
}
}
if(score.isPresent()){
Transaction tx = jedis.multi();
tx.zrem(queue, old);
tx.zadd(queue, score.get(), newJob.toJSONString());
tx.exec();
}
}
}
}
示例2: remove
import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
/**
* Remove a message completely.
*
* @param msg
* @return
*/
protected boolean remove(IQueueMessage<ID, DATA> msg) {
if (isEphemeralDisabled()) {
return true;
}
try (Jedis jedis = jedisPool.getResource()) {
Transaction jt = jedis.multi();
byte[] field = msg.qId().toString().getBytes(QueueUtils.UTF8);
Response<Long> response = jt.hdel(redisHashName, field);
jt.zrem(redisSortedSetName, field);
jt.exec();
Long value = response.get();
return value != null && value.longValue() > 1;
}
}
示例3: prioritize
import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public synchronized void prioritize(int jobId) {
try (Jedis jedis = jedisPool.getResource()) {
jedis.select(redisDBIndex);
if (jedis.zcard(queue) > 0) {
double minScore = -1;
String selectedMember = null;
Set<Tuple> tuples = jedis.zrangeByScoreWithScores(queue, 0, Double.MAX_VALUE);
for(Tuple data : tuples) {
JSONObject detail = JSONObject.parseObject(data.getElement());
int id = detail.getIntValue(ScheduledConstants.JOB_ID);
// retrieve minimum score
if(minScore < 0) {
minScore = data.getScore();
}
if(id == jobId) {
selectedMember = data.getElement();
break;
}
}
Transaction tx = jedis.multi();
tx.zrem(queue, selectedMember);
double newScore = minScore - 1;
tx.zadd(queue, newScore, selectedMember);
tx.exec();
}
}
}
示例4: storeOld
import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
/**
* Re-store an old message (called by {@link #requeue(IQueueMessage)} or
* {@link #requeueSilent(IQueueMessage)}.
*
* @param msg
* @return
*/
protected boolean storeOld(IQueueMessage<ID, DATA> msg) {
try (Jedis jedis = jedisPool.getResource()) {
Transaction jt = jedis.multi();
byte[] field = msg.qId().toString().getBytes(QueueUtils.UTF8);
byte[] data = serialize(msg);
jt.hset(redisHashName, field, data);
jt.rpush(redisListName, field);
jt.zrem(redisSortedSetName, field);
jt.exec();
return true;
}
}