add:Redis新增列表支持
This commit is contained in:
parent
8661d8f3e7
commit
c36044e6e4
@ -13,6 +13,7 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@ -155,6 +156,40 @@ public class RedisTools {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static long list_add(String listName, String... value) {
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(QQBOT_USER);
|
||||
long index = jedis.sadd(listName, value);
|
||||
jedis.close();
|
||||
return index;
|
||||
}
|
||||
|
||||
public static Set<String> list_get(String listName) {
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(QQBOT_USER);
|
||||
Set<String> set = jedis.smembers(listName);
|
||||
jedis.close();
|
||||
if (set == null) {
|
||||
set = new HashSet<>();
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public static boolean list_remove(String listName, String... value) {
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(QQBOT_USER);
|
||||
long index = jedis.srem(listName, value);
|
||||
jedis.close();
|
||||
return index != 0;
|
||||
}
|
||||
|
||||
public static boolean list_isExist(String listName, String value) {
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(QQBOT_USER);
|
||||
boolean flag = jedis.sismember(listName, value);
|
||||
jedis.close();
|
||||
return flag;
|
||||
}
|
||||
public static Jedis getRedis() {
|
||||
return new Jedis(host, port);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user