重构代码.

This commit is contained in:
lijiahangmax
2023-11-21 01:11:44 +08:00
parent 8fe105fc8a
commit 69c71055d9
9 changed files with 98 additions and 70 deletions

View File

@@ -82,6 +82,18 @@ public class RedisLists extends RedisUtils {
.collect(Collectors.toList());
}
/**
* list 添加元素
*
* @param define define
* @param list list
* @param mapper mapper
* @param <T> T
*/
public static <T> void pushAll(CacheKeyDefine define, List<T> list, Function<T, String> mapper) {
pushAll(define.getKey(), define, list, mapper);
}
/**
* list 添加元素
*
@@ -91,7 +103,23 @@ public class RedisLists extends RedisUtils {
* @param <T> T
*/
public static <T> void pushAll(String key, List<T> list, Function<T, String> mapper) {
pushAll(key, null, list, mapper);
}
/**
* list 添加元素
*
* @param key key
* @param define define
* @param list list
* @param mapper mapper
* @param <T> T
*/
public static <T> void pushAll(String key, CacheKeyDefine define, List<T> list, Function<T, String> mapper) {
redisTemplate.opsForList().rightPushAll(key, Lists.map(list, mapper));
if (define != null) {
setExpire(key, define);
}
}
/**