本文整理匯總了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;
}