Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
5dc0935d
Commit
5dc0935d
authored
May 23, 2022
by
陶湘宇
Committed by
284718418@qq.com
Mar 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复redis缓存不能持久生效
parent
051cd5fc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
src/main/java/cn/timer/api/aspect/RequestAop.java
+0
-0
src/main/java/cn/timer/api/config/interceptor/RedisSessionInterceptor.java
+17
-4
src/main/java/cn/timer/api/utils/redis/RedisUtil.java
+4
-0
No files found.
src/main/java/cn/timer/api/aspect/RequestAop.java
View file @
5dc0935d
src/main/java/cn/timer/api/config/interceptor/RedisSessionInterceptor.java
View file @
5dc0935d
...
...
@@ -51,10 +51,23 @@ public class RedisSessionInterceptor implements HandlerInterceptor {
*/
// 无论访问的地址是不是正确的,都进行登录验证,登录成功后的访问再进行分发,404的访问自然会进入到错误控制器中
HttpSession
session
=
request
.
getSession
();
System
.
out
.
println
(
"SID===="
+
session
.
getId
());
Object
ai
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ai"
);
Object
ui
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
);
//String Sid
System
.
out
.
println
(
"RSID==------=="
+
session
.
getId
());
System
.
out
.
println
(
"ROSID=-----==="
+
request
.
getRequestedSessionId
());
/**
* 新ID替换旧ID完成登陆
*/
if
(
session
.
getId
()!=
request
.
getRequestedSessionId
()&&
redisUtil
.
hasKey
(
request
.
getRequestedSessionId
())&&
redisUtil
.
getAttribute
(
session
.
getId
(),
"ai"
)==
null
){
try
{
redisUtil
.
reNmae
(
request
.
getRequestedSessionId
(),
session
.
getId
());
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
Object
nai
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ai"
);
Object
nui
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
);
Object
ai
=
nai
!=
null
?
nai:
redisUtil
.
getAttribute
(
request
.
getRequestedSessionId
(),
"ai"
);
Object
ui
=
nui
!=
null
?
nui:
redisUtil
.
getAttribute
(
request
.
getRequestedSessionId
(),
"ui"
);
if
(
ui
==
null
&&
ai
==
null
)
{
response401
(
response
);
return
false
;
...
...
src/main/java/cn/timer/api/utils/redis/RedisUtil.java
View file @
5dc0935d
...
...
@@ -608,9 +608,13 @@ public class RedisUtil {
public
Object
rifhtPop
(
String
listKey
){
//绑定操作
BoundListOperations
<
String
,
Object
>
boundValueOperations
=
redisTemplate
.
boundListOps
(
listKey
);
return
boundValueOperations
.
rightPop
();
}
public
void
reNmae
(
String
oldKey
,
String
newKey
){
redisTemplate
.
rename
(
oldKey
,
newKey
);
}
//=========BoundListOperations 用法 End============
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment