Commit a57224c3 authored by yanzg's avatar yanzg

表结构修改

parent 24261ecb
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;
} }
......
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