mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-14 06:03:42 +08:00
fix:RedisUtils相关修改
This commit is contained in:
@@ -17,11 +17,9 @@ import java.util.stream.Collectors;
|
|||||||
public class RedisUtils {
|
public class RedisUtils {
|
||||||
|
|
||||||
private static StringRedisTemplate stringRedisTemplate;
|
private static StringRedisTemplate stringRedisTemplate;
|
||||||
private static RedisTemplate<String, Object> redisTemplate;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
RedisUtils.stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
|
RedisUtils.stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
|
||||||
RedisUtils.redisTemplate = SpringUtil.getBean("myRedisTemplate");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String LUA_INCR_EXPIRE =
|
private static final String LUA_INCR_EXPIRE =
|
||||||
@@ -67,7 +65,7 @@ public class RedisUtils {
|
|||||||
public static Boolean expire(String key, long time, TimeUnit timeUnit) {
|
public static Boolean expire(String key, long time, TimeUnit timeUnit) {
|
||||||
try {
|
try {
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
redisTemplate.expire(key, time, timeUnit);
|
stringRedisTemplate.expire(key, time, timeUnit);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@@ -104,7 +102,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static List<String> scan(String pattern) {
|
public static List<String> scan(String pattern) {
|
||||||
ScanOptions options = ScanOptions.scanOptions().match(pattern).build();
|
ScanOptions options = ScanOptions.scanOptions().match(pattern).build();
|
||||||
RedisConnectionFactory factory = redisTemplate.getConnectionFactory();
|
RedisConnectionFactory factory = stringRedisTemplate.getConnectionFactory();
|
||||||
RedisConnection rc = Objects.requireNonNull(factory).getConnection();
|
RedisConnection rc = Objects.requireNonNull(factory).getConnection();
|
||||||
Cursor<byte[]> cursor = rc.scan(options);
|
Cursor<byte[]> cursor = rc.scan(options);
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
@@ -129,7 +127,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static List<String> findKeysForPage(String patternKey, int page, int size) {
|
public static List<String> findKeysForPage(String patternKey, int page, int size) {
|
||||||
ScanOptions options = ScanOptions.scanOptions().match(patternKey).build();
|
ScanOptions options = ScanOptions.scanOptions().match(patternKey).build();
|
||||||
RedisConnectionFactory factory = redisTemplate.getConnectionFactory();
|
RedisConnectionFactory factory = stringRedisTemplate.getConnectionFactory();
|
||||||
RedisConnection rc = Objects.requireNonNull(factory).getConnection();
|
RedisConnection rc = Objects.requireNonNull(factory).getConnection();
|
||||||
Cursor<byte[]> cursor = rc.scan(options);
|
Cursor<byte[]> cursor = rc.scan(options);
|
||||||
List<String> result = new ArrayList<>(size);
|
List<String> result = new ArrayList<>(size);
|
||||||
@@ -165,7 +163,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean hasKey(String key) {
|
public static Boolean hasKey(String key) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.hasKey(key);
|
return stringRedisTemplate.hasKey(key);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return false;
|
return false;
|
||||||
@@ -188,7 +186,7 @@ public class RedisUtils {
|
|||||||
Set<String> keySet = new HashSet<>();
|
Set<String> keySet = new HashSet<>();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
Set<String> stringSet = stringRedisTemplate.keys(key);
|
Set<String> stringSet = stringRedisTemplate.keys(key);
|
||||||
if(Objects.nonNull(stringSet) && !stringSet.isEmpty()){
|
if (Objects.nonNull(stringSet) && !stringSet.isEmpty()) {
|
||||||
keySet.addAll(stringSet);
|
keySet.addAll(stringSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,10 +270,10 @@ public class RedisUtils {
|
|||||||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
||||||
* @return true成功 false 失败
|
* @return true成功 false 失败
|
||||||
*/
|
*/
|
||||||
public Boolean set(String key, Object value, long time) {
|
public static Boolean set(String key, Object value, long time) {
|
||||||
try {
|
try {
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
stringRedisTemplate.opsForValue().set(key, objToStr(value), time, TimeUnit.SECONDS);
|
||||||
} else {
|
} else {
|
||||||
set(key, value);
|
set(key, value);
|
||||||
}
|
}
|
||||||
@@ -319,7 +317,7 @@ public class RedisUtils {
|
|||||||
* @return 值
|
* @return 值
|
||||||
*/
|
*/
|
||||||
public static Object hget(String key, String item) {
|
public static Object hget(String key, String item) {
|
||||||
return redisTemplate.opsForHash().get(key, item);
|
return stringRedisTemplate.opsForHash().get(key, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -329,7 +327,7 @@ public class RedisUtils {
|
|||||||
* @return 对应的多个键值
|
* @return 对应的多个键值
|
||||||
*/
|
*/
|
||||||
public static Map<Object, Object> hmget(String key) {
|
public static Map<Object, Object> hmget(String key) {
|
||||||
return redisTemplate.opsForHash().entries(key);
|
return stringRedisTemplate.opsForHash().entries(key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +340,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean hmset(String key, Map<String, Object> map) {
|
public static Boolean hmset(String key, Map<String, Object> map) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForHash().putAll(key, map);
|
stringRedisTemplate.opsForHash().putAll(key, map);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@@ -360,7 +358,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean hmset(String key, Map<String, Object> map, long time) {
|
public static Boolean hmset(String key, Map<String, Object> map, long time) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForHash().putAll(key, map);
|
stringRedisTemplate.opsForHash().putAll(key, map);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
expire(key, time);
|
expire(key, time);
|
||||||
}
|
}
|
||||||
@@ -381,7 +379,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean hset(String key, String item, Object value) {
|
public static Boolean hset(String key, String item, Object value) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForHash().put(key, item, value);
|
stringRedisTemplate.opsForHash().put(key, item, value);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@@ -400,7 +398,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean hset(String key, String item, Object value, long time) {
|
public static Boolean hset(String key, String item, Object value, long time) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForHash().put(key, item, value);
|
stringRedisTemplate.opsForHash().put(key, item, value);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
expire(key, time);
|
expire(key, time);
|
||||||
}
|
}
|
||||||
@@ -418,7 +416,7 @@ public class RedisUtils {
|
|||||||
* @param item 项 可以使多个 不能为null
|
* @param item 项 可以使多个 不能为null
|
||||||
*/
|
*/
|
||||||
public static void hdel(String key, Object... item) {
|
public static void hdel(String key, Object... item) {
|
||||||
redisTemplate.opsForHash().delete(key, item);
|
stringRedisTemplate.opsForHash().delete(key, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -429,7 +427,7 @@ public class RedisUtils {
|
|||||||
* @return true 存在 false不存在
|
* @return true 存在 false不存在
|
||||||
*/
|
*/
|
||||||
public static Boolean hHasKey(String key, String item) {
|
public static Boolean hHasKey(String key, String item) {
|
||||||
return redisTemplate.opsForHash().hasKey(key, item);
|
return stringRedisTemplate.opsForHash().hasKey(key, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -441,7 +439,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Double hincr(String key, String item, double by) {
|
public static Double hincr(String key, String item, double by) {
|
||||||
return redisTemplate.opsForHash().increment(key, item, by);
|
return stringRedisTemplate.opsForHash().increment(key, item, by);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,7 +451,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Double hdecr(String key, String item, double by) {
|
public static Double hdecr(String key, String item, double by) {
|
||||||
return redisTemplate.opsForHash().increment(key, item, -by);
|
return stringRedisTemplate.opsForHash().increment(key, item, -by);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================set=============================
|
// ============================set=============================
|
||||||
@@ -464,9 +462,9 @@ public class RedisUtils {
|
|||||||
* @param key 键
|
* @param key 键
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<Object> sGet(String key) {
|
public static Set<String> sGet(String key) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForSet().members(key);
|
return stringRedisTemplate.opsForSet().members(key);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
@@ -482,7 +480,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean sHasKey(String key, Object value) {
|
public static Boolean sHasKey(String key, Object value) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForSet().isMember(key, value);
|
return stringRedisTemplate.opsForSet().isMember(key, value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return false;
|
return false;
|
||||||
@@ -498,7 +496,11 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Long sSet(String key, Object... values) {
|
public static Long sSet(String key, Object... values) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForSet().add(key, values);
|
String[] s = new String[values.length];
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
s[i] = objToStr(values[i]);
|
||||||
|
}
|
||||||
|
return stringRedisTemplate.opsForSet().add(key, s);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return 0L;
|
return 0L;
|
||||||
@@ -515,7 +517,11 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Long sSetAndTime(String key, long time, Object... values) {
|
public static Long sSetAndTime(String key, long time, Object... values) {
|
||||||
try {
|
try {
|
||||||
Long count = redisTemplate.opsForSet().add(key, values);
|
String[] s = new String[values.length];
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
s[i] = objToStr(values[i]);
|
||||||
|
}
|
||||||
|
Long count = stringRedisTemplate.opsForSet().add(key, s);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
expire(key, time);
|
expire(key, time);
|
||||||
}
|
}
|
||||||
@@ -534,7 +540,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Long sGetSetSize(String key) {
|
public static Long sGetSetSize(String key) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForSet().size(key);
|
return stringRedisTemplate.opsForSet().size(key);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return 0L;
|
return 0L;
|
||||||
@@ -550,7 +556,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Long setRemove(String key, Object... values) {
|
public static Long setRemove(String key, Object... values) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForSet().remove(key, values);
|
return stringRedisTemplate.opsForSet().remove(key, values);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return 0L;
|
return 0L;
|
||||||
@@ -567,9 +573,9 @@ public class RedisUtils {
|
|||||||
* @param end 结束 0 到 -1代表所有值
|
* @param end 结束 0 到 -1代表所有值
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List<Object> lGet(String key, long start, long end) {
|
public static List<String> lGet(String key, long start, long end) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForList().range(key, start, end);
|
return stringRedisTemplate.opsForList().range(key, start, end);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
@@ -584,7 +590,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Long lGetListSize(String key) {
|
public static Long lGetListSize(String key) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForList().size(key);
|
return stringRedisTemplate.opsForList().size(key);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return 0L;
|
return 0L;
|
||||||
@@ -598,9 +604,9 @@ public class RedisUtils {
|
|||||||
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
|
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Object lGetIndex(String key, long index) {
|
public static String lGetIndex(String key, long index) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForList().index(key, index);
|
return stringRedisTemplate.opsForList().index(key, index);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
@@ -616,7 +622,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean lSet(String key, Object value) {
|
public static Boolean lSet(String key, Object value) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForList().rightPush(key, value);
|
stringRedisTemplate.opsForList().rightPush(key, objToStr(value));
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@@ -634,7 +640,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean lSet(String key, Object value, long time) {
|
public static Boolean lSet(String key, Object value, long time) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForList().rightPush(key, value);
|
stringRedisTemplate.opsForList().rightPush(key, objToStr(value));
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
expire(key, time);
|
expire(key, time);
|
||||||
}
|
}
|
||||||
@@ -654,7 +660,11 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean lSet(String key, List<Object> value) {
|
public static Boolean lSet(String key, List<Object> value) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForList().rightPushAll(key, value);
|
List<String> list = new ArrayList<>();
|
||||||
|
for (Object item : value) {
|
||||||
|
list.add(objToStr(item));
|
||||||
|
}
|
||||||
|
stringRedisTemplate.opsForList().rightPushAll(key, list);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@@ -672,7 +682,11 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean lSet(String key, List<Object> value, long time) {
|
public static Boolean lSet(String key, List<Object> value, long time) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForList().rightPushAll(key, value);
|
List<String> list = new ArrayList<>();
|
||||||
|
for (Object item : value) {
|
||||||
|
list.add(objToStr(item));
|
||||||
|
}
|
||||||
|
stringRedisTemplate.opsForList().rightPushAll(key, list);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
expire(key, time);
|
expire(key, time);
|
||||||
}
|
}
|
||||||
@@ -693,7 +707,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean lUpdateIndex(String key, long index, Object value) {
|
public static Boolean lUpdateIndex(String key, long index, Object value) {
|
||||||
try {
|
try {
|
||||||
redisTemplate.opsForList().set(key, index, value);
|
stringRedisTemplate.opsForList().set(key, index, objToStr(value));
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
@@ -711,7 +725,7 @@ public class RedisUtils {
|
|||||||
*/
|
*/
|
||||||
public static Long lRemove(String key, long count, Object value) {
|
public static Long lRemove(String key, long count, Object value) {
|
||||||
try {
|
try {
|
||||||
return redisTemplate.opsForList().remove(key, count, value);
|
return stringRedisTemplate.opsForList().remove(key, count, value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return 0L;
|
return 0L;
|
||||||
@@ -725,12 +739,12 @@ public class RedisUtils {
|
|||||||
public void delByKeys(String prefix, Set<Long> ids) {
|
public void delByKeys(String prefix, Set<Long> ids) {
|
||||||
Set<String> keys = new HashSet<>();
|
Set<String> keys = new HashSet<>();
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
Set<String> stringSet = redisTemplate.keys(prefix + id);
|
Set<String> stringSet = stringRedisTemplate.keys(prefix + id);
|
||||||
if (Objects.nonNull(stringSet) && !stringSet.isEmpty()) {
|
if (Objects.nonNull(stringSet) && !stringSet.isEmpty()) {
|
||||||
keys.addAll(stringSet);
|
keys.addAll(stringSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long count = redisTemplate.delete(keys);
|
Long count = stringRedisTemplate.delete(keys);
|
||||||
// 此处提示可自行删除
|
// 此处提示可自行删除
|
||||||
log.debug("--------------------------------------------");
|
log.debug("--------------------------------------------");
|
||||||
log.debug("成功删除缓存:" + keys.toString());
|
log.debug("成功删除缓存:" + keys.toString());
|
||||||
@@ -764,8 +778,8 @@ public class RedisUtils {
|
|||||||
* @param values
|
* @param values
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zAdd(String key, Set<TypedTuple<Object>> values) {
|
public Long zAdd(String key, Set<TypedTuple<String>> values) {
|
||||||
return redisTemplate.opsForZSet().add(key, values);
|
return stringRedisTemplate.opsForZSet().add(key, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -774,7 +788,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zRemove(String key, Object... values) {
|
public static Long zRemove(String key, Object... values) {
|
||||||
return redisTemplate.opsForZSet().remove(key, values);
|
return stringRedisTemplate.opsForZSet().remove(key, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Long zRemove(String key, Object value) {
|
public static Long zRemove(String key, Object value) {
|
||||||
@@ -794,7 +808,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Double zIncrementScore(String key, String value, double delta) {
|
public static Double zIncrementScore(String key, String value, double delta) {
|
||||||
return redisTemplate.opsForZSet().incrementScore(key, value, delta);
|
return stringRedisTemplate.opsForZSet().incrementScore(key, value, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -805,7 +819,7 @@ public class RedisUtils {
|
|||||||
* @return 0表示第一位
|
* @return 0表示第一位
|
||||||
*/
|
*/
|
||||||
public static Long zRank(String key, Object value) {
|
public static Long zRank(String key, Object value) {
|
||||||
return redisTemplate.opsForZSet().rank(key, value);
|
return stringRedisTemplate.opsForZSet().rank(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -816,7 +830,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zReverseRank(String key, Object value) {
|
public static Long zReverseRank(String key, Object value) {
|
||||||
return redisTemplate.opsForZSet().reverseRank(key, value);
|
return stringRedisTemplate.opsForZSet().reverseRank(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -827,8 +841,8 @@ public class RedisUtils {
|
|||||||
* @param end 结束位置, -1查询所有
|
* @param end 结束位置, -1查询所有
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<Object> zRange(String key, long start, long end) {
|
public static Set<String> zRange(String key, long start, long end) {
|
||||||
return redisTemplate.opsForZSet().range(key, start, end);
|
return stringRedisTemplate.opsForZSet().range(key, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -839,9 +853,9 @@ public class RedisUtils {
|
|||||||
* @param end
|
* @param end
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<ZSetOperations.TypedTuple<Object>> zRangeWithScores(String key, long start,
|
public static Set<ZSetOperations.TypedTuple<String>> zRangeWithScores(String key, long start,
|
||||||
long end) {
|
long end) {
|
||||||
return redisTemplate.opsForZSet().rangeWithScores(key, start, end);
|
return stringRedisTemplate.opsForZSet().rangeWithScores(key, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -852,8 +866,8 @@ public class RedisUtils {
|
|||||||
* @param max 最大值
|
* @param max 最大值
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<Object> zRangeByScore(String key, double min, double max) {
|
public static Set<String> zRangeByScore(String key, double min, double max) {
|
||||||
return redisTemplate.opsForZSet().rangeByScore(key, min, max);
|
return stringRedisTemplate.opsForZSet().rangeByScore(key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -864,9 +878,9 @@ public class RedisUtils {
|
|||||||
* @param max 最大值
|
* @param max 最大值
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<TypedTuple<Object>> zRangeByScoreWithScores(String key,
|
public Set<TypedTuple<String>> zRangeByScoreWithScores(String key,
|
||||||
double min, double max) {
|
double min, double max) {
|
||||||
return redisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max);
|
return stringRedisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -877,9 +891,9 @@ public class RedisUtils {
|
|||||||
* @param end
|
* @param end
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<TypedTuple<Object>> zRangeByScoreWithScores(String key,
|
public static Set<TypedTuple<String>> zRangeByScoreWithScores(String key,
|
||||||
double min, double max, long start, long end) {
|
double min, double max, long start, long end) {
|
||||||
return redisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max,
|
return stringRedisTemplate.opsForZSet().rangeByScoreWithScores(key, min, max,
|
||||||
start, end);
|
start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -891,8 +905,8 @@ public class RedisUtils {
|
|||||||
* @param end
|
* @param end
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<Object> zReverseRange(String key, long start, long end) {
|
public static Set<String> zReverseRange(String key, long start, long end) {
|
||||||
return redisTemplate.opsForZSet().reverseRange(key, start, end);
|
return stringRedisTemplate.opsForZSet().reverseRange(key, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
@@ -971,7 +985,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zCount(String key, double min, double max) {
|
public static Long zCount(String key, double min, double max) {
|
||||||
return redisTemplate.opsForZSet().count(key, min, max);
|
return stringRedisTemplate.opsForZSet().count(key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -981,7 +995,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zSize(String key) {
|
public static Long zSize(String key) {
|
||||||
return redisTemplate.opsForZSet().size(key);
|
return stringRedisTemplate.opsForZSet().size(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1002,7 +1016,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Double zScore(String key, Object value) {
|
public static Double zScore(String key, Object value) {
|
||||||
return redisTemplate.opsForZSet().score(key, value);
|
return stringRedisTemplate.opsForZSet().score(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1014,7 +1028,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zRemoveRange(String key, long start, long end) {
|
public static Long zRemoveRange(String key, long start, long end) {
|
||||||
return redisTemplate.opsForZSet().removeRange(key, start, end);
|
return stringRedisTemplate.opsForZSet().removeRange(key, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1026,7 +1040,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zRemoveRangeByScore(String key, double min, double max) {
|
public static Long zRemoveRangeByScore(String key, double min, double max) {
|
||||||
return redisTemplate.opsForZSet().removeRangeByScore(key, min, max);
|
return stringRedisTemplate.opsForZSet().removeRangeByScore(key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1038,7 +1052,7 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zUnionAndStore(String key, String otherKey, String destKey) {
|
public static Long zUnionAndStore(String key, String otherKey, String destKey) {
|
||||||
return redisTemplate.opsForZSet().unionAndStore(key, otherKey, destKey);
|
return stringRedisTemplate.opsForZSet().unionAndStore(key, otherKey, destKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1048,8 +1062,8 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zUnionAndStore(String key, Collection<String> otherKeys,
|
public static Long zUnionAndStore(String key, Collection<String> otherKeys,
|
||||||
String destKey) {
|
String destKey) {
|
||||||
return redisTemplate.opsForZSet()
|
return stringRedisTemplate.opsForZSet()
|
||||||
.unionAndStore(key, otherKeys, destKey);
|
.unionAndStore(key, otherKeys, destKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1062,8 +1076,8 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zIntersectAndStore(String key, String otherKey,
|
public static Long zIntersectAndStore(String key, String otherKey,
|
||||||
String destKey) {
|
String destKey) {
|
||||||
return redisTemplate.opsForZSet().intersectAndStore(key, otherKey,
|
return stringRedisTemplate.opsForZSet().intersectAndStore(key, otherKey,
|
||||||
destKey);
|
destKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1076,8 +1090,8 @@ public class RedisUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Long zIntersectAndStore(String key, Collection<String> otherKeys,
|
public static Long zIntersectAndStore(String key, Collection<String> otherKeys,
|
||||||
String destKey) {
|
String destKey) {
|
||||||
return redisTemplate.opsForZSet().intersectAndStore(key, otherKeys,
|
return stringRedisTemplate.opsForZSet().intersectAndStore(key, otherKeys,
|
||||||
destKey);
|
destKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user