Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
a57224c3
Commit
a57224c3
authored
Jul 05, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表结构修改
parent
24261ecb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
CacheLock.java
...-redis/src/main/java/com.yanzuoguang.redis/CacheLock.java
+18
-6
No files found.
yzg-util-redis/src/main/java/com.yanzuoguang.redis/CacheLock.java
View file @
a57224c3
package
com
.
yanzuoguang
.
redis
;
package
com
.
yanzuoguang
.
redis
;
import
com.alicp.jetcache.Cache
;
import
com.alicp.jetcache.Cache
;
import
com.yanzuoguang.util.exception.RuntimeCodeException
;
import
com.yanzuoguang.util.helper.YzgTimeout
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -48,6 +50,10 @@ public class CacheLock<T, M> implements Runnable {
...
@@ -48,6 +50,10 @@ public class CacheLock<T, M> implements Runnable {
* 等待次数
* 等待次数
*/
*/
private
int
waitCount
;
private
int
waitCount
;
/**
* 最长等待次数
*/
private
int
maxWaitCount
=
30
;
/**
/**
* 构造函数
* 构造函数
...
@@ -129,17 +135,23 @@ public class CacheLock<T, M> implements Runnable {
...
@@ -129,17 +135,23 @@ public class CacheLock<T, M> implements Runnable {
this
.
waitCount
++;
this
.
waitCount
++;
ThreadHelper
.
sleep
(
waitUnitTime
);
ThreadHelper
.
sleep
(
waitUnitTime
);
}
}
if
(
this
.
waitCount
>=
this
.
maxWaitCount
)
{
cache
.
remove
(
key
);
throw
new
RuntimeCodeException
(
"等待执行超时"
);
}
}
while
(!
runFlag
);
}
while
(!
runFlag
);
}
}
private
void
funcRun
()
{
private
void
funcRun
()
{
try
{
try
{
if
(
this
.
waitCount
>
0
&&
this
.
funcWait
!=
null
)
{
YzgTimeout
.
timeOut
(
this
.
getClass
(),
this
.
key
.
toString
(),
()
->
{
funcWait
.
run
();
if
(
this
.
waitCount
>
0
&&
this
.
funcWait
!=
null
)
{
}
funcWait
.
run
();
if
(
this
.
func
!=
null
)
{
}
func
.
run
();
if
(
this
.
func
!=
null
)
{
}
func
.
run
();
}
});
}
finally
{
}
finally
{
runFlag
=
true
;
runFlag
=
true
;
}
}
...
...
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