use of redis.clients.jedis.JedisPool in project warn-report by saaavsaaa.
the class JRedisPool method buildRedisPool.
private void buildRedisPool() {
properties = new RedisProperties();
try {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(properties.getMaxTotal());
config.setMaxIdle(properties.getMaxIdle());
config.setMaxWaitMillis(properties.getMaxWait());
// 在获取连接的时候检查有效性, 默认false
config.setTestOnBorrow(properties.isTestOnBorrow());
// 在空闲时检查有效性, 默认false
config.setTestWhileIdle(properties.isTestWhileIdle());
jedisPool = new JedisPool(config, properties.getIp(), properties.getPort(), properties.getTimeout(), properties.getAuth());
} catch (Exception e) {
System.out.println("case : new JedisPoolConfig or JedisPool error, detail : " + e.getMessage());
}
}
use of redis.clients.jedis.JedisPool in project tech by ffyyhh995511.
the class JedisService method lpush.
/*################################################## 列表(List) 命令 ######################################################################*/
/**
* list 左存储
* @param key
* @param value
* @return
*/
public long lpush(String key, String value) {
long rs = 0;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.lpush(key, value);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return rs;
}
use of redis.clients.jedis.JedisPool in project tech by ffyyhh995511.
the class JedisService method zadd.
/*########################## 有序集合(sorted set) 命令 ########################## */
/**
* 排序集合
* @param key
* @param score
* @param member
* @return
*/
public long zadd(String key, double score, String member) {
long rs = 0;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.zadd(key, score, member);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return rs;
}
use of redis.clients.jedis.JedisPool in project tech by ffyyhh995511.
the class JedisService method hvals.
/**
* 返回哈希的值(values)
* @param key
* @return
*/
public List<String> hvals(String key) {
List<String> rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.hvals(key);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return rs;
}
use of redis.clients.jedis.JedisPool in project tech by ffyyhh995511.
the class JedisService method del.
/**
* 字符串删除
* @param key
*/
public long del(String... key) {
long rs = 0;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.del(key);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return rs;
}
Aggregations