Commit a57224c3 authored by yanzg's avatar yanzg

表结构修改

parent 24261ecb
package com.yanzuoguang.redis;
import com.alicp.jetcache.Cache;
import com.yanzuoguang.util.exception.RuntimeCodeException;
import com.yanzuoguang.util.helper.YzgTimeout;
import com.yanzuoguang.util.thread.ThreadHelper;
import java.util.concurrent.TimeUnit;
......@@ -48,6 +50,10 @@ public class CacheLock<T, M> implements Runnable {
* 等待次数
*/
private int waitCount;
/**
* 最长等待次数
*/
private int maxWaitCount = 30;
/**
* 构造函数
......@@ -129,17 +135,23 @@ public class CacheLock<T, M> implements Runnable {
this.waitCount++;
ThreadHelper.sleep(waitUnitTime);
}
if (this.waitCount >= this.maxWaitCount) {
cache.remove(key);
throw new RuntimeCodeException("等待执行超时");
}
} while (!runFlag);
}
private void funcRun() {
try {
if (this.waitCount > 0 && this.funcWait != null) {
funcWait.run();
}
if (this.func != null) {
func.run();
}
YzgTimeout.timeOut(this.getClass(), this.key.toString(), () -> {
if (this.waitCount > 0 && this.funcWait != null) {
funcWait.run();
}
if (this.func != null) {
func.run();
}
});
} finally {
runFlag = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment