use of redis.clients.jedis.JedisPool in project tech by ffyyhh995511.
the class JedisService method flushAll.
/**
* 删除所有数据库的所有key
* @return
*/
public String flushAll() {
String rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.flushAll();
}
} 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 sismember.
/**
* 判断member 是否是存在key集合(set)中
* @param key
* @param member
* @return
*/
public Boolean sismember(String key, String member) {
Boolean rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.sismember(key, 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 mget.
/**
* 字符串批量获取
* @param keys
* @return
*/
public List<String> mget(String... keys) {
List<String> rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.mget(keys);
}
} 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 sadd.
/*################## set集合命令(无序) ###################*/
/**
* set集合存储,一次可以插入多个value
* @param key
* @param members
* @return
*/
public Long sadd(String key, String... members) {
Long rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.sadd(key, members);
}
} 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 scard.
/**
* 返回set集合的长度
* @param key
* @return
*/
public Long scard(String key) {
Long rs = null;
Jedis jedis = null;
JedisPool jedisPool = null;
try {
jedisPool = getJedisPool();
jedis = jedisPool.getResource();
if (jedis != null) {
rs = jedis.scard(key);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return rs;
}
Aggregations