本文整理汇总了Java中redis.clients.jedis.Jedis.incrBy方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.incrBy方法的具体用法?Java Jedis.incrBy怎么用?Java Jedis.incrBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.incrBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: incrBy
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public Long incrBy(String key, long value) {
Jedis jedis = null;
boolean success = true;
long ret = -1;
try {
jedis = jedisPool.getResource();
if (jedis == null) {
success = false;
return ret;
}
ret = jedis.incrBy(key, value);
} catch (Exception e) {
success = false;
returnBrokenResource(jedis, "incrBy:" + key, e);
} finally {
releaseReidsSource(success, jedis);
}
return ret;
}
示例2: executeTask
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private void executeTask(TopicViewCountTask task) {
Jedis jedis = redisManager.getJedis();
String cacheValue = jedis.get(task.getKey());
int count = cacheValue == null ? 0 : Integer.valueOf(cacheValue);
if (count < 2) {
jedis.incrBy(task.getKey(), task.getViews());
} else {
jedis.del(task.getKey());
topicService.updateTopicViews(Long.valueOf(task.getTopicId()), count + task.getViews());
}
redisManager.retureRes(jedis);
}
示例3: incrBy
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Long incrBy(String key, Long integer) {
Jedis jedis = null;
Long res = null;
try {
jedis = pool.getResource();
res = jedis.incrBy(key, integer);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
returnResource(pool, jedis);
}
return res;
}
示例4: increaseBy
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public Long increaseBy(String key, long offset) {
Jedis jedis = null;
Long var5;
try {
jedis = pool.getResource();
var5 = jedis.incrBy(key, offset);
} catch (Exception var9) {
throw new RuntimeException(var9);
} finally {
pool.returnResourceObject(jedis);
}
return var5;
}