From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 19 五月 2020 17:13:23 +0800
Subject: [PATCH] 饿了么绘图,添加口碑

---
 fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableServiceAspect.java |   31 +++++++------------------------
 1 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableServiceAspect.java b/fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableServiceAspect.java
index 99bf3b7..ffc756e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableServiceAspect.java
+++ b/fanli/src/main/java/com/yeshi/fanli/aspect/RequestSerializableServiceAspect.java
@@ -17,13 +17,13 @@
 import org.springframework.expression.spel.support.StandardEvaluationContext;
 import org.springframework.stereotype.Component;
 
-import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
 
 import redis.clients.jedis.Jedis;
 import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.params.SetParams;
 
 @Component
 @Aspect
@@ -70,52 +70,38 @@
 						Jedis jedis = jedisPool.getResource();
 						try {
 							Constant.waitingThreadSet.add(Thread.currentThread().getId());
-							long result = 0;
+							String result = null;
 							long startTime = System.currentTimeMillis();
 							// 绛夊緟鍝嶅簲
-							while (result <= 0) {
-								result = jedis.setnx(cacheKey, "1");
-								if (result <= 0) {
+							while (StringUtil.isNullOrEmpty(result)) {
+								result = jedis.set(cacheKey, "1", new SetParams().nx().ex(30));
+								if (StringUtil.isNullOrEmpty(result)) {
 									try {
-										System.out.println("__________宸叉湁绾跨▼鍦ㄦ墽琛�");
 										Thread.sleep(50);
 									} catch (InterruptedException e) {
 										e.printStackTrace();
 									}
 									if (System.currentTimeMillis() - startTime > 1000 * 60L) {
 										Constant.waitingThreadSet.remove(Thread.currentThread().getId());
-										System.out.println("__________鍒犻櫎绾跨▼");
 										return null;
 									}
-								} else {
-									// 璁剧疆30绉掑鐞嗘椂闂�
-									jedis.expire(cacheKey, 30);
 								}
 							}
 
-							if (result > 0) {
+							if (!StringUtil.isNullOrEmpty(result)) {
 								try {
-									System.out.println("__________鏀捐鎵ц");
 									return joinPoint.proceed();
-								} catch (Throwable e) {
-									e.printStackTrace();
-									LogHelper.errorDetailInfo(e);
 								} finally {
 									jedis.del(cacheKey);
 									Constant.waitingThreadSet.remove(Thread.currentThread().getId());
 								}
 							}
 						} finally {
-							jedisPool.returnResource(jedis);
+							jedis.close();
 						}
 					}
 				} catch (Exception e) {// 鍘熷瓙鎬т繚鎶ゅ嚭閿�
-					try {
 						return joinPoint.proceed();
-					} catch (Throwable e1) {
-						e.printStackTrace();
-						LogHelper.errorDetailInfo(e1);
-					}
 				}
 			}
 		} catch (NoSuchMethodException e) {
@@ -123,9 +109,6 @@
 		} catch (SecurityException e) {
 			e.printStackTrace();
 		}
-
 		return joinPoint.proceed();
-		
 	}
-
 }

--
Gitblit v1.8.0