Skip to content
GitLab
探索
登录
注册
主导航
搜索或转到…
项目
S
Saber
管理
动态
成员
标记
计划
议题
0
议题看板
里程碑
Wiki
代码
合并请求
0
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
软件包库
模型注册表
运维
环境
Terraform 模块
监控
事件
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为 GitLab 提交贡献
提交反馈
快捷键
?
代码片段
群组
项目
Show more breadcrumbs
SaberLink
Saber
合并请求
!49
[Feature#]解决泛型类型强制转换报错
代码
评审变更
检出分支
下载
补丁
文本差异
已合并
[Feature#]解决泛型类型强制转换报错
feat/weibingrui
至
main
概览
0
提交
1
流水线
0
变更
1
已合并
韦秉芮
请求将
feat/weibingrui
合并到
main
1年前
概览
0
提交
1
流水线
0
变更
1
展开
0
0
合并请求报告
比较
main
main (源)
和
最新版本
最新版本
eeeee7d9
1 次提交,
1年前
1 文件
+
4
−
15
内联
比较变更
并排
内联
显示空白变更内容
一次显示一个文件
src/main/java/com/steadon/saber/util/RedisUtils.java
+
4
−
15
操作
@@ -4,7 +4,6 @@ import lombok.AllArgsConstructor;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
@@ -49,7 +48,7 @@ public class RedisUtils {
* @param list the list to cache
*/
public
<
T
>
void
setList
(
String
key
,
List
<
T
>
list
)
{
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
list
);
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
list
.
toArray
()
);
}
/**
@@ -64,19 +63,9 @@ public class RedisUtils {
if
(
rawList
==
null
)
{
return
Collections
.
emptyList
();
}
List
<
T
>
resultList
=
new
ArrayList
<>(
rawList
.
size
());
for
(
Object
o
:
rawList
)
{
if
(
clazz
.
isInstance
(
o
))
{
resultList
.
add
(
clazz
.
cast
(
o
));
}
else
{
// Handle the case where the object is not of type T.
// Depending on your application logic, you might want to throw an exception,
// log a warning, or skip the item.
throw
new
IllegalArgumentException
(
"Cached list contains elements not of type "
+
clazz
.
getName
());
}
}
return
resultList
;
return
rawList
.
stream
().
filter
(
clazz:
:
isInstance
)
.
map
(
clazz:
:
cast
)
.
toList
();
}
// 检查Key是否存在
加载中