WANG 5 年之前
父節點
當前提交
e0fc8a64b2
共有 1 個文件被更改,包括 19 次插入14 次删除
  1. 19 14
      src/main/java/cn/com/qmth/examcloud/web/cache/ObjectRedisCacheProcessor.java

+ 19 - 14
src/main/java/cn/com/qmth/examcloud/web/cache/ObjectRedisCacheProcessor.java

@@ -83,6 +83,13 @@ public class ObjectRedisCacheProcessor {
 
 			while (true) {
 				count++;
+
+				t = getRedisClient().get(key, c);
+
+				if (null != t) {
+					break;
+				}
+
 				Boolean locked = getRedisClient().setIfAbsent(cacheLock,
 						ThreadLocalUtil.getTraceId(), 30);
 
@@ -90,6 +97,7 @@ public class ObjectRedisCacheProcessor {
 					try {
 						getObjectRedisCacheTrigger().fire(appName, className, propKeys);
 						getRedisClient().delete(cacheException);
+						t = getRedisClient().get(key, c);
 						break;
 					} catch (Exception e) {
 						getRedisClient().set(cacheException, true, 60);
@@ -97,25 +105,22 @@ public class ObjectRedisCacheProcessor {
 					} finally {
 						getRedisClient().delete(cacheLock);
 					}
-				}
+				} else {
 
-				t = getRedisClient().get(key, c);
+					if (null != getRedisClient().get(cacheException, Boolean.class)) {
+						throw new ExamCloudRuntimeException(
+								"exception happened when loading cache. key=" + key);
+					}
 
-				if (null != t) {
-					break;
-				}
+					// 10秒内未加载完缓存,抛出异常
+					if (200 < count) {
+						throw new ExamCloudRuntimeException(
+								"fail to load cache in 10 seconds. key=" + key);
+					}
 
-				if (null != getRedisClient().get(cacheException, Boolean.class)) {
-					throw new ExamCloudRuntimeException(
-							"exception happened when loading cache. key=" + key);
-				}
+					Util.sleep(TimeUnit.MILLISECONDS, 30);
 
-				// 10秒内未加载完缓存,抛出异常
-				if (200 < count) {
-					throw new ExamCloudRuntimeException(
-							"fail to load cache in 10 seconds. key=" + key);
 				}
-				Util.sleep(TimeUnit.MILLISECONDS, 50);
 			}
 
 		}