@@ -8,24 +8,18 @@ import org.springframework.data.redis.core.*;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple ;
import org.springframework.data.redis.core.script.DefaultRedisScript ;
import org.springframework.data.redis.core.script.RedisScript ;
import org.springframework.stereotype.Component ;
import javax.annotation.PostConstruct ;
import java.util.* ;
import java.util.concurrent.TimeUnit ;
import java.util.stream.Collectors ;
@Slf4j
@Component
public class RedisUtils {
public RedisTemplate redisTemplate ;
private static StringRedisTemplate stringRedisTemplate ;
@PostConstruct
public void init ( ) {
this . stringRedisTemplate = SpringUtil . getBean ( StringRedisTemplate . class ) ;
static {
RedisUtils . stringRedisTemplate = SpringUtil . getBean ( StringRedisTemplate . class ) ;
}
private static final String LUA_INCR_EXPIRE =
@@ -49,7 +43,7 @@ public class RedisUtils {
* @param key 键
* @param time 时间(秒)
*/
public static b oolean expire ( String key , long time ) {
public static B oolean expire ( String key , long time ) {
try {
if ( time > 0 ) {
stringRedisTemplate . expire ( key , time , TimeUnit . SECONDS ) ;
@@ -68,10 +62,10 @@ public class RedisUtils {
* @param time 时间(秒)
* @param timeUnit 单位
*/
public b oolean expire ( String key , long time , TimeUnit timeUnit ) {
public static B oolean expire ( String key , long time , TimeUnit timeUnit ) {
try {
if ( time > 0 ) {
r edisTemplate. expire ( key , time , timeUnit ) ;
stringR edisTemplate. expire ( key , time , timeUnit ) ;
}
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
@@ -86,7 +80,7 @@ public class RedisUtils {
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public static l ong getExpire ( String key ) {
public static L ong getExpire ( String key ) {
return stringRedisTemplate . getExpire ( key , TimeUnit . SECONDS ) ;
}
@@ -96,7 +90,7 @@ public class RedisUtils {
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public static l ong getExpire ( String key , TimeUnit timeUnit ) {
public static L ong getExpire ( String key , TimeUnit timeUnit ) {
return stringRedisTemplate . getExpire ( key , timeUnit ) ;
}
@@ -106,9 +100,9 @@ public class RedisUtils {
* @param pattern key
* @return /
*/
public List < String > scan ( String pattern ) {
public static List < String > scan ( String pattern ) {
ScanOptions options = ScanOptions . scanOptions ( ) . match ( pattern ) . build ( ) ;
RedisConnectionFactory factory = r edisTemplate. getConnectionFactory ( ) ;
RedisConnectionFactory factory = stringR edisTemplate. getConnectionFactory ( ) ;
RedisConnection rc = Objects . requireNonNull ( factory ) . getConnection ( ) ;
Cursor < byte [ ] > cursor = rc . scan ( options ) ;
List < String > result = new ArrayList < > ( ) ;
@@ -131,9 +125,9 @@ public class RedisUtils {
* @param size 每页数目
* @return /
*/
public 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 ( ) ;
RedisConnectionFactory factory = r edisTemplate. getConnectionFactory ( ) ;
RedisConnectionFactory factory = stringR edisTemplate. getConnectionFactory ( ) ;
RedisConnection rc = Objects . requireNonNull ( factory ) . getConnection ( ) ;
Cursor < byte [ ] > cursor = rc . scan ( options ) ;
List < String > result = new ArrayList < > ( size ) ;
@@ -167,9 +161,9 @@ public class RedisUtils {
* @param key 键
* @return true 存在 false不存在
*/
public b oolean hasKey ( String key ) {
public static B oolean hasKey ( String key ) {
try {
return r edisTemplate. hasKey ( key ) ;
return stringR edisTemplate. hasKey ( key ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return false ;
@@ -185,21 +179,23 @@ public class RedisUtils {
public static void del ( String . . . keys ) {
if ( keys ! = null & & keys . length > 0 ) {
if ( keys . length = = 1 ) {
b oolean result = stringRedisTemplate . delete ( keys [ 0 ] ) ;
log . debug ( " -------------------------------------------- " ) ;
log . debug ( new StringBuilder ( " 删除缓存: " ) . append ( keys [ 0 ] ) . append ( " ,结果: " ) . append ( result ) . toString ( ) ) ;
B oolean result = stringRedisTemplate . delete ( keys [ 0 ] ) ;
log . debug ( " -------------------------------------------- " ) ;
log . debug ( " 删除缓存: " + keys [ 0 ] + " ,结果: " + result ) ;
} else {
Set < String > keySet = new HashSet < > ( ) ;
for ( String key : keys ) {
keySet . addAll ( stringRedisTemplate . keys ( key ) ) ;
Set < String > stringSet = stringRedisTemplate . keys ( key ) ;
if ( Objects . nonNull ( stringSet ) & & ! stringSet . isEmpty ( ) ) {
keySet . addAll ( stringSet ) ;
}
}
l ong count = stringRedisTemplate . delete ( keySet ) ;
L ong count = stringRedisTemplate . delete ( keySet ) ;
log . debug ( " -------------------------------------------- " ) ;
log . debug ( " 成功删除缓存: " + keySet . toString ( ) );
log . debug ( " 成功删除缓存: " + keySet ) ;
log . debug ( " 缓存删除数量: " + count + " 个 " ) ;
log . debug ( " -------------------------------------------- " ) ;
}
log . debug ( " -------------------------------------------- " ) ;
}
}
@@ -222,7 +218,7 @@ public class RedisUtils {
* @param value 值
* @return true成功 false失败
*/
public static b oolean set ( String key , Object value ) {
public static B oolean set ( String key , Object value ) {
try {
stringRedisTemplate . opsForValue ( ) . set ( key , objToStr ( value ) ) ;
return true ;
@@ -243,7 +239,10 @@ public class RedisUtils {
public static < T > List < T > mget ( Collection < String > keys , Class < T > tClass ) {
List < String > list = stringRedisTemplate . opsForValue ( ) . multiGet ( keys ) ;
return ( List < T > ) list . stream ( ) . map ( o - > toBeanOrNull ( o , tClass ) ) . collect ( Collectors . toL ist( ) ) ;
if ( Objects . isNull ( l ist) ) {
return new ArrayList < > ( ) ;
}
return list . stream ( ) . map ( o - > toBeanOrNull ( o , tClass ) ) . collect ( Collectors . toList ( ) ) ;
}
static < T > T toBeanOrNull ( String json , Class < T > tClass ) {
@@ -271,10 +270,10 @@ public class RedisUtils {
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
* @return true成功 false 失败
*/
public b oolean set ( String key , Object value , long time ) {
public static B oolean set ( String key , Object value , long time ) {
try {
if ( time > 0 ) {
r edisTemplate. opsForValue ( ) . set ( key , value , time , TimeUnit . SECONDS ) ;
stringR edisTemplate. opsForValue ( ) . set ( key , objToStr ( value) , time , TimeUnit . SECONDS ) ;
} else {
set ( key , value ) ;
}
@@ -294,7 +293,7 @@ public class RedisUtils {
* @param timeUnit 类型
* @return true成功 false 失败
*/
public static b oolean set ( String key , Object value , long time , TimeUnit timeUnit ) {
public static B oolean set ( String key , Object value , long time , TimeUnit timeUnit ) {
try {
if ( time > 0 ) {
stringRedisTemplate . opsForValue ( ) . set ( key , objToStr ( value ) , time , timeUnit ) ;
@@ -317,8 +316,8 @@ public class RedisUtils {
* @param item 项 不能为null
* @return 值
*/
public Object hget ( String key , String item ) {
return r edisTemplate. opsForHash ( ) . get ( key , item ) ;
public static Object hget ( String key , String item ) {
return stringR edisTemplate. opsForHash ( ) . get ( key , item ) ;
}
/**
@@ -327,8 +326,8 @@ public class RedisUtils {
* @param key 键
* @return 对应的多个键值
*/
public Map < Object , Object > hmget ( String key ) {
return r edisTemplate. opsForHash ( ) . entries ( key ) ;
public static Map < Object , Object > hmget ( String key ) {
return stringR edisTemplate. opsForHash ( ) . entries ( key ) ;
}
@@ -339,9 +338,9 @@ public class RedisUtils {
* @param map 对应多个键值
* @return true 成功 false 失败
*/
public b oolean hmset ( String key , Map < String , Object > map ) {
public static B oolean hmset ( String key , Map < String , Object > map ) {
try {
r edisTemplate. opsForHash ( ) . putAll ( key , map ) ;
stringR edisTemplate. opsForHash ( ) . putAll ( key , map ) ;
return true ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
@@ -357,9 +356,9 @@ public class RedisUtils {
* @param time 时间(秒)
* @return true成功 false失败
*/
public b oolean hmset ( String key , Map < String , Object > map , long time ) {
public static B oolean hmset ( String key , Map < String , Object > map , long time ) {
try {
r edisTemplate. opsForHash ( ) . putAll ( key , map ) ;
stringR edisTemplate. opsForHash ( ) . putAll ( key , map ) ;
if ( time > 0 ) {
expire ( key , time ) ;
}
@@ -378,9 +377,9 @@ public class RedisUtils {
* @param value 值
* @return true 成功 false失败
*/
public b oolean hset ( String key , String item , Object value ) {
public static B oolean hset ( String key , String item , Object value ) {
try {
r edisTemplate. opsForHash ( ) . put ( key , item , value ) ;
stringR edisTemplate. opsForHash ( ) . put ( key , item , value ) ;
return true ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
@@ -397,9 +396,9 @@ public class RedisUtils {
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true 成功 false失败
*/
public b oolean hset ( String key , String item , Object value , long time ) {
public static B oolean hset ( String key , String item , Object value , long time ) {
try {
r edisTemplate. opsForHash ( ) . put ( key , item , value ) ;
stringR edisTemplate. opsForHash ( ) . put ( key , item , value ) ;
if ( time > 0 ) {
expire ( key , time ) ;
}
@@ -416,8 +415,8 @@ public class RedisUtils {
* @param key 键 不能为null
* @param item 项 可以使多个 不能为null
*/
public void hdel ( String key , Object . . . item ) {
r edisTemplate. opsForHash ( ) . delete ( key , item ) ;
public static void hdel ( String key , Object . . . item ) {
stringR edisTemplate. opsForHash ( ) . delete ( key , item ) ;
}
/**
@@ -427,8 +426,8 @@ public class RedisUtils {
* @param item 项 不能为null
* @return true 存在 false不存在
*/
public b oolean hHasKey ( String key , String item ) {
return r edisTemplate. opsForHash ( ) . hasKey ( key , item ) ;
public static B oolean hHasKey ( String key , String item ) {
return stringR edisTemplate. opsForHash ( ) . hasKey ( key , item ) ;
}
/**
@@ -439,8 +438,8 @@ public class RedisUtils {
* @param by 要增加几(大于0)
* @return
*/
public d ouble hincr ( String key , String item , double by ) {
return r edisTemplate. opsForHash ( ) . increment ( key , item , by ) ;
public static D ouble hincr ( String key , String item , double by ) {
return stringR edisTemplate. opsForHash ( ) . increment ( key , item , by ) ;
}
/**
@@ -451,8 +450,8 @@ public class RedisUtils {
* @param by 要减少记(小于0)
* @return
*/
public d ouble hdecr ( String key , String item , double by ) {
return r edisTemplate. opsForHash ( ) . increment ( key , item , - by ) ;
public static D ouble hdecr ( String key , String item , double by ) {
return stringR edisTemplate. opsForHash ( ) . increment ( key , item , - by ) ;
}
// ============================set=============================
@@ -463,9 +462,9 @@ public class RedisUtils {
* @param key 键
* @return
*/
public Set < Object > sGet ( String key ) {
public static Set < String > sGet ( String key ) {
try {
return r edisTemplate. opsForSet ( ) . members ( key ) ;
return stringR edisTemplate. opsForSet ( ) . members ( key ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return null ;
@@ -479,9 +478,9 @@ public class RedisUtils {
* @param value 值
* @return true 存在 false不存在
*/
public b oolean sHasKey ( String key , Object value ) {
public static B oolean sHasKey ( String key , Object value ) {
try {
return r edisTemplate. opsForSet ( ) . isMember ( key , value ) ;
return stringR edisTemplate. opsForSet ( ) . isMember ( key , value ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return false ;
@@ -495,12 +494,16 @@ public class RedisUtils {
* @param values 值 可以是多个
* @return 成功个数
*/
public l ong sSet ( String key , Object . . . values ) {
public static L ong sSet ( String key , Object . . . values ) {
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 ) {
log . error ( e . getMessage ( ) , e ) ;
return 0 ;
return 0L ;
}
}
@@ -512,16 +515,20 @@ public class RedisUtils {
* @param values 值 可以是多个
* @return 成功个数
*/
public l ong sSetAndTime ( String key , long time , Object . . . values ) {
public static L ong sSetAndTime ( String key , long time , Object . . . values ) {
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 ) {
expire ( key , time ) ;
}
return count ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return 0 ;
return 0L ;
}
}
@@ -531,12 +538,12 @@ public class RedisUtils {
* @param key 键
* @return
*/
public l ong sGetSetSize ( String key ) {
public static L ong sGetSetSize ( String key ) {
try {
return r edisTemplate. opsForSet ( ) . size ( key ) ;
return stringR edisTemplate. opsForSet ( ) . size ( key ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return 0 ;
return 0L ;
}
}
@@ -547,13 +554,12 @@ public class RedisUtils {
* @param values 值 可以是多个
* @return 移除的个数
*/
public l ong setRemove ( String key , Object . . . values ) {
public static L ong setRemove ( String key , Object . . . values ) {
try {
Long count = r edisTemplate. opsForSet ( ) . remove ( key , values ) ;
return count ;
return stringR edisTemplate. opsForSet ( ) . remove ( key , values ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return 0 ;
return 0L ;
}
}
@@ -567,9 +573,9 @@ public class RedisUtils {
* @param end 结束 0 到 -1代表所有值
* @return
*/
public List < Object > lGet ( String key , long start , long end ) {
public static List < String > lGet ( String key , long start , long end ) {
try {
return r edisTemplate. opsForList ( ) . range ( key , start , end ) ;
return stringR edisTemplate. opsForList ( ) . range ( key , start , end ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return null ;
@@ -582,12 +588,12 @@ public class RedisUtils {
* @param key 键
* @return
*/
public l ong lGetListSize ( String key ) {
public static L ong lGetListSize ( String key ) {
try {
return r edisTemplate. opsForList ( ) . size ( key ) ;
return stringR edisTemplate. opsForList ( ) . size ( key ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return 0 ;
return 0L ;
}
}
@@ -598,9 +604,9 @@ public class RedisUtils {
* @param index 索引 index>=0时, 0 表头, 1 第二个元素, 依次类推; index<0时, -1, 表尾, -2倒数第二个元素, 依次类推
* @return
*/
public Object lGetIndex ( String key , long index ) {
public static String lGetIndex ( String key , long index ) {
try {
return r edisTemplate. opsForList ( ) . index ( key , index ) ;
return stringR edisTemplate. opsForList ( ) . index ( key , index ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return null ;
@@ -614,9 +620,9 @@ public class RedisUtils {
* @param value 值
* @return
*/
public b oolean lSet ( String key , Object value ) {
public static B oolean lSet ( String key , Object value ) {
try {
r edisTemplate. opsForList ( ) . rightPush ( key , value ) ;
stringR edisTemplate. opsForList ( ) . rightPush ( key , objToStr ( value) ) ;
return true ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
@@ -632,9 +638,9 @@ public class RedisUtils {
* @param time 时间(秒)
* @return
*/
public b oolean lSet ( String key , Object value , long time ) {
public static B oolean lSet ( String key , Object value , long time ) {
try {
r edisTemplate. opsForList ( ) . rightPush ( key , value ) ;
stringR edisTemplate. opsForList ( ) . rightPush ( key , objToStr ( value) ) ;
if ( time > 0 ) {
expire ( key , time ) ;
}
@@ -652,9 +658,13 @@ public class RedisUtils {
* @param value 值
* @return
*/
public b oolean lSet ( String key , List < Object > value ) {
public static B oolean lSet ( String key , List < Object > value ) {
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 ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
@@ -670,9 +680,13 @@ public class RedisUtils {
* @param time 时间(秒)
* @return
*/
public b oolean lSet ( String key , List < Object > value , long time ) {
public static B oolean lSet ( String key , List < Object > value , long time ) {
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 ) {
expire ( key , time ) ;
}
@@ -691,9 +705,9 @@ public class RedisUtils {
* @param value 值
* @return /
*/
public b oolean lUpdateIndex ( String key , long index , Object value ) {
public static B oolean lUpdateIndex ( String key , long index , Object value ) {
try {
r edisTemplate. opsForList ( ) . set ( key , index , value ) ;
stringR edisTemplate. opsForList ( ) . set ( key , index , objToStr ( value) ) ;
return true ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
@@ -709,12 +723,12 @@ public class RedisUtils {
* @param value 值
* @return 移除的个数
*/
public l ong lRemove ( String key , long count , Object value ) {
public static L ong lRemove ( String key , long count , Object value ) {
try {
return r edisTemplate. opsForList ( ) . remove ( key , count , value ) ;
return stringR edisTemplate. opsForList ( ) . remove ( key , count , value ) ;
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
return 0 ;
return 0L ;
}
}
@@ -723,11 +737,14 @@ public class RedisUtils {
* @param ids id
*/
public void delByKeys ( String prefix , Set < Long > ids ) {
Set < Object > keys = new HashSet < > ( ) ;
Set < String > keys = new HashSet < > ( ) ;
for ( Long id : ids ) {
keys . addAll ( redisTemplate . keys ( new StringBuffer ( prefix ) . append ( id ) . toString ( ) ) ) ;
Set < String > stringSet = stringRedisTemplate . keys ( prefix + id ) ;
if ( Objects . nonNull ( stringSet ) & & ! stringSet . isEmpty ( ) ) {
keys . addAll ( stringSet ) ;
}
}
l ong count = r edisTemplate. delete ( keys ) ;
L ong count = stringR edisTemplate. delete ( keys ) ;
// 此处提示可自行删除
log . debug ( " -------------------------------------------- " ) ;
log . debug ( " 成功删除缓存: " + keys . toString ( ) ) ;
@@ -762,7 +779,7 @@ public class RedisUtils {
* @return
*/
public Long zAdd ( String key , Set < TypedTuple < String > > values ) {
return r edisTemplate. opsForZSet ( ) . add ( key , values ) ;
return stringR edisTemplate. opsForZSet ( ) . add ( key , values ) ;
}
/**
@@ -770,8 +787,8 @@ public class RedisUtils {
* @param values
* @return
*/
public Long zRemove ( String key , Object . . . values ) {
return r edisTemplate. opsForZSet ( ) . remove ( key , values ) ;
public static Long zRemove ( String key , Object . . . values ) {
return stringR edisTemplate. opsForZSet ( ) . remove ( key , values ) ;
}
public static Long zRemove ( String key , Object value ) {
@@ -790,8 +807,8 @@ public class RedisUtils {
* @param delta
* @return
*/
public Double zIncrementScore ( String key , String value , double delta ) {
return r edisTemplate. opsForZSet ( ) . incrementScore ( key , value , delta ) ;
public static Double zIncrementScore ( String key , String value , double delta ) {
return stringR edisTemplate. opsForZSet ( ) . incrementScore ( key , value , delta ) ;
}
/**
@@ -801,8 +818,8 @@ public class RedisUtils {
* @param value
* @return 0表示第一位
*/
public Long zRank ( String key , Object value ) {
return r edisTemplate. opsForZSet ( ) . rank ( key , value ) ;
public static Long zRank ( String key , Object value ) {
return stringR edisTemplate. opsForZSet ( ) . rank ( key , value ) ;
}
/**
@@ -812,8 +829,8 @@ public class RedisUtils {
* @param value
* @return
*/
public Long zReverseRank ( String key , Object value ) {
return r edisTemplate. opsForZSet ( ) . reverseRank ( key , value ) ;
public static Long zReverseRank ( String key , Object value ) {
return stringR edisTemplate. opsForZSet ( ) . reverseRank ( key , value ) ;
}
/**
@@ -824,8 +841,8 @@ public class RedisUtils {
* @param end 结束位置, -1查询所有
* @return
*/
public Set < String > zRange ( String key , long start , long end ) {
return r edisTemplate. opsForZSet ( ) . range ( key , start , end ) ;
public static Set < String > zRange ( String key , long start , long end ) {
return stringR edisTemplate. opsForZSet ( ) . range ( key , start , end ) ;
}
/**
@@ -836,9 +853,9 @@ public class RedisUtils {
* @param end
* @return
*/
public Set < ZSetOperations . TypedTuple < String > > zRangeWithScores ( String key , long start ,
long end ) {
return r edisTemplate. opsForZSet ( ) . rangeWithScores ( key , start , end ) ;
public static Set < ZSetOperations . TypedTuple < String > > zRangeWithScores ( String key , long start ,
long end ) {
return stringR edisTemplate. opsForZSet ( ) . rangeWithScores ( key , start , end ) ;
}
/**
@@ -849,8 +866,8 @@ public class RedisUtils {
* @param max 最大值
* @return
*/
public Set < String > zRangeByScore ( String key , double min , double max ) {
return r edisTemplate. opsForZSet ( ) . rangeByScore ( key , min , max ) ;
public static Set < String > zRangeByScore ( String key , double min , double max ) {
return stringR edisTemplate. opsForZSet ( ) . rangeByScore ( key , min , max ) ;
}
/**
@@ -863,7 +880,7 @@ public class RedisUtils {
*/
public Set < TypedTuple < String > > zRangeByScoreWithScores ( String key ,
double min , double max ) {
return r edisTemplate. opsForZSet ( ) . rangeByScoreWithScores ( key , min , max ) ;
return stringR edisTemplate. opsForZSet ( ) . rangeByScoreWithScores ( key , min , max ) ;
}
/**
@@ -874,9 +891,9 @@ public class RedisUtils {
* @param end
* @return
*/
public Set < TypedTuple < String > > zRangeByScoreWithScores ( String key ,
double min , double max , long start , long end ) {
return r edisTemplate. opsForZSet ( ) . rangeByScoreWithScores ( key , min , max ,
public static Set < TypedTuple < String > > zRangeByScoreWithScores ( String key ,
double min , double max , long start , long end ) {
return stringR edisTemplate. opsForZSet ( ) . rangeByScoreWithScores ( key , min , max ,
start , end ) ;
}
@@ -888,8 +905,8 @@ public class RedisUtils {
* @param end
* @return
*/
public Set < String > zReverseRange ( String key , long start , long end ) {
return r edisTemplate. opsForZSet ( ) . reverseRange ( key , start , end ) ;
public static Set < String > zReverseRange ( String key , long start , long end ) {
return stringR edisTemplate. opsForZSet ( ) . reverseRange ( key , start , end ) ;
}
// /**
@@ -967,8 +984,8 @@ public class RedisUtils {
* @param max
* @return
*/
public Long zCount ( String key , double min , double max ) {
return r edisTemplate. opsForZSet ( ) . count ( key , min , max ) ;
public static Long zCount ( String key , double min , double max ) {
return stringR edisTemplate. opsForZSet ( ) . count ( key , min , max ) ;
}
/**
@@ -977,8 +994,8 @@ public class RedisUtils {
* @param key
* @return
*/
public Long zSize ( String key ) {
return r edisTemplate. opsForZSet ( ) . size ( key ) ;
public static Long zSize ( String key ) {
return stringR edisTemplate. opsForZSet ( ) . size ( key ) ;
}
/**
@@ -998,8 +1015,8 @@ public class RedisUtils {
* @param value
* @return
*/
public Double zScore ( String key , Object value ) {
return r edisTemplate. opsForZSet ( ) . score ( key , value ) ;
public static Double zScore ( String key , Object value ) {
return stringR edisTemplate. opsForZSet ( ) . score ( key , value ) ;
}
/**
@@ -1010,8 +1027,8 @@ public class RedisUtils {
* @param end
* @return
*/
public Long zRemoveRange ( String key , long start , long end ) {
return r edisTemplate. opsForZSet ( ) . removeRange ( key , start , end ) ;
public static Long zRemoveRange ( String key , long start , long end ) {
return stringR edisTemplate. opsForZSet ( ) . removeRange ( key , start , end ) ;
}
/**
@@ -1022,8 +1039,8 @@ public class RedisUtils {
* @param max
* @return
*/
public Long zRemoveRangeByScore ( String key , double min , double max ) {
return r edisTemplate. opsForZSet ( ) . removeRangeByScore ( key , min , max ) ;
public static Long zRemoveRangeByScore ( String key , double min , double max ) {
return stringR edisTemplate. opsForZSet ( ) . removeRangeByScore ( key , min , max ) ;
}
/**
@@ -1034,8 +1051,8 @@ public class RedisUtils {
* @param destKey
* @return
*/
public Long zUnionAndStore ( String key , String otherKey , String destKey ) {
return r edisTemplate. opsForZSet ( ) . unionAndStore ( key , otherKey , destKey ) ;
public static Long zUnionAndStore ( String key , String otherKey , String destKey ) {
return stringR edisTemplate. opsForZSet ( ) . unionAndStore ( key , otherKey , destKey ) ;
}
/**
@@ -1044,9 +1061,9 @@ public class RedisUtils {
* @param destKey
* @return
*/
public Long zUnionAndStore ( String key , Collection < String > otherKeys ,
String destKey ) {
return r edisTemplate. opsForZSet ( )
public static Long zUnionAndStore ( String key , Collection < String > otherKeys ,
String destKey ) {
return stringR edisTemplate. opsForZSet ( )
. unionAndStore ( key , otherKeys , destKey ) ;
}
@@ -1058,9 +1075,9 @@ public class RedisUtils {
* @param destKey
* @return
*/
public Long zIntersectAndStore ( String key , String otherKey ,
String destKey ) {
return r edisTemplate. opsForZSet ( ) . intersectAndStore ( key , otherKey ,
public static Long zIntersectAndStore ( String key , String otherKey ,
String destKey ) {
return stringR edisTemplate. opsForZSet ( ) . intersectAndStore ( key , otherKey ,
destKey ) ;
}
@@ -1072,9 +1089,9 @@ public class RedisUtils {
* @param destKey
* @return
*/
public Long zIntersectAndStore ( String key , Collection < String > otherKeys ,
String destKey ) {
return r edisTemplate. opsForZSet ( ) . intersectAndStore ( key , otherKeys ,
public static Long zIntersectAndStore ( String key , Collection < String > otherKeys ,
String destKey ) {
return stringR edisTemplate. opsForZSet ( ) . intersectAndStore ( key , otherKeys ,
destKey ) ;
}