Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wj-datacenter-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jinan
wj-datacenter-platform
Commits
136a02c5
Commit
136a02c5
authored
May 28, 2024
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 Redis 清理任务
parent
9bb4f53c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
RedisTask.java
...ce/src/main/java/net/wanji/datacenter/task/RedisTask.java
+4
-1
RedisUtils.java
...e/src/main/java/net/wanji/datacenter/util/RedisUtils.java
+9
-0
No files found.
wj-datacenter-service/src/main/java/net/wanji/datacenter/task/RedisTask.java
View file @
136a02c5
...
@@ -2,6 +2,7 @@ package net.wanji.datacenter.task;
...
@@ -2,6 +2,7 @@ package net.wanji.datacenter.task;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.datacenter.util.RedisUtils
;
import
net.wanji.datacenter.util.RedisUtils
;
import
org.springframework.data.redis.connection.DataType
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -28,7 +29,9 @@ public class RedisTask {
...
@@ -28,7 +29,9 @@ public class RedisTask {
try
{
try
{
Set
<
String
>
keys
=
redisUtils
.
keys
();
Set
<
String
>
keys
=
redisUtils
.
keys
();
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
redisUtils
.
removeExpiredElements
(
key
);
if
(
redisUtils
.
keyType
(
key
)
==
DataType
.
ZSET
)
{
redisUtils
.
removeExpiredElements
(
key
);
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"清理路口事件缓存失败"
,
e
);
log
.
error
(
"清理路口事件缓存失败"
,
e
);
...
...
wj-datacenter-service/src/main/java/net/wanji/datacenter/util/RedisUtils.java
View file @
136a02c5
package
net
.
wanji
.
datacenter
.
util
;
package
net
.
wanji
.
datacenter
.
util
;
import
net.wanji.datacenter.constant.Constant
;
import
net.wanji.datacenter.constant.Constant
;
import
org.springframework.data.redis.connection.DataType
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.ValueOperations
;
import
org.springframework.data.redis.core.ValueOperations
;
import
org.springframework.data.redis.support.atomic.RedisAtomicLong
;
import
org.springframework.data.redis.support.atomic.RedisAtomicLong
;
...
@@ -300,6 +301,14 @@ public class RedisUtils {
...
@@ -300,6 +301,14 @@ public class RedisUtils {
return
redisTemplate
.
keys
(
"*"
);
return
redisTemplate
.
keys
(
"*"
);
}
}
/**
* 获取key的类型
* @return
*/
public
DataType
keyType
(
String
key
)
{
return
redisTemplate
.
type
(
key
);
}
/**
/**
* 获取全局ID范围
* 获取全局ID范围
*
*
...
...
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