Commit 0f7adddc by zt

修改

parent 6753e606
......@@ -18,6 +18,30 @@ public class RedisUtils {
private JedisPool jedisPool;
/**
* 通过key 对value进行加值+1操作,当value不是int类型时会返回错误,当key不存在是则value为1
* 自增不取消过期时间
*
* @param key
* @return 加值后的结果
*/
public Long incrNotResetExpireTime(String key, int indexDb) {
Jedis jedis = null;
Long res = null;
try {
jedis = jedisPool.getResource();
jedis.select(indexDb);
Long expireTime = jedis.pttl(key);
res = jedis.incr(key);
jedis.expireAt(key, expireTime);
} catch (Exception e) {
log.error(e.getMessage());
} finally {
returnResource(jedisPool, jedis);
}
return res;
}
/**
* 删除key
*
* @param key
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment