| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import org.aspectj.lang.ProceedingJoinPoint;
|
| | | import org.aspectj.lang.Signature;
|
| | | import org.aspectj.lang.annotation.Around;
|
| | |
| | | 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;
|
| | |
| | | public class RequestSerializableServiceAspect {
|
| | |
|
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | | private RedisManager redisManager;
|
| | |
|
| | | private ExpressionParser parser = new SpelExpressionParser();
|
| | |
|
| | |
| | | + cacheKey;
|
| | | cacheKey = "service-" + StringUtil.Md5(cacheKey);
|
| | | // jiedis原子性做拦截
|
| | | Jedis jedis = jedisPool.getResource();
|
| | | Jedis jedis = redisManager.getJedis();
|
| | | try {
|
| | | Constant.waitingThreadSet.add(Thread.currentThread().getId());
|
| | | String result = null;
|
| | |
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | try {
|
| | | return joinPoint.proceed();
|
| | | } catch (Throwable e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } finally {
|
| | | jedis.del(cacheKey);
|
| | | Constant.waitingThreadSet.remove(Thread.currentThread().getId());
|
| | |
| | | }
|
| | | }
|
| | | } catch (Exception e) {// 原子性保护出错
|
| | | try {
|
| | | return joinPoint.proceed();
|
| | | } catch (Throwable e1) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e1);
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (NoSuchMethodException e) {
|