Commit 85db83df by Administrator

Merge branch 'feature/1006372-1' into 'master'

feat:[1006372]新增redis工具方法

See merge request rays/pcloud-common-parent!242
parents 07922b73 035f9458
......@@ -870,6 +870,20 @@ public class JedisClusterUtils {
}
return null;
}
/**
* spop
*
* @param key
* @return
*/
public static String spop(String key) {
try {
return jedisCluster.spop(key);
} catch (Exception e) {
LOGGER.warn("jedis列表出栈(spop)失败:" + e.getMessage(), e);
}
return null;
}
/**
* 列表出栈(左端)
......@@ -1533,4 +1547,84 @@ public class JedisClusterUtils {
}
return result;
}
/**
* 查看 set 中是否存在指定元素
*
* @param key
* @param value
* @return
*/
public static Boolean sismember(String key,String value) {
Boolean result = null;
try {
result=jedisCluster.sismember(key,value);
} catch (Exception e) {
LOGGER.warn("查看 set 中是否存在指定元素:" + e.getMessage(), e);
}
return result;
}
/**
* 设置 bit
* @param key
* @param offset
* @param value
* @return
*/
public static Boolean setbit(String key, long offset,boolean value) {
Boolean result = null;
try {
return jedisCluster.setbit(key, offset, true);
} catch (Exception e) {
LOGGER.warn("设置 bit 异常:" + e.getMessage(), e);
}
return result;
}
/**
* 读取bit
* @param key
* @param offset
* @return
*/
public static Boolean getbit(String key, long offset) {
Boolean result = null;
try {
return jedisCluster.getbit(key, offset);
} catch (Exception e) {
LOGGER.warn("读取 bit 异常:" + e.getMessage(), e);
}
return result;
}
/**
* 统计bit 为1的数量
* @param key
* @return
*/
public static Long bitcount(String key) {
Long result = null;
try {
return jedisCluster.bitcount(key);
} catch (Exception e) {
LOGGER.warn("计数 bit 异常:" + e.getMessage(), e);
}
return result;
}
/**
* 统计bit 为1的数量
* @param key
* @param start 起始byte数,0开始
* @param end 结束byte数
* @return
*/
public static Long bitcount(String key,long start,long end) {
Long result = null;
try {
return jedisCluster.bitcount(key,start,end);
} catch (Exception e) {
LOGGER.warn("计数 bit 异常:" + e.getMessage(), e);
}
return result;
}
}
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