diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index e43091e47..e7301b51c 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -14,6 +14,8 @@ ruoyi:
addressEnabled: false
# 验证码类型 math 数组计算 char 字符验证
captchaType: math
+ # 是否开启 redis 缓存,true 开启,false 关闭
+ redisOpen: false
# 开发环境配置
server:
@@ -124,3 +126,5 @@ xss:
excludes: /system/notice/*
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
+
+
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 46823fe71..aa8887dad 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -34,6 +34,11 @@
org.springframework.boot
spring-boot-starter-security
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisAspect.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisAspect.java
new file mode 100644
index 000000000..c261ded19
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisAspect.java
@@ -0,0 +1,36 @@
+package com.ruoyi.common.core.redis;
+
+import com.ruoyi.common.exception.CustomException;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Aspect
+@Component
+public class RedisAspect {
+ private Logger logger = LoggerFactory.getLogger(getClass());
+ /**
+ * 是否开启redis缓存 true开启 false关闭
+ */
+ @Value("${ruoyi.redisOpen: false}")
+ private boolean open;
+
+ @Around("execution(* com.ruoyi.common.core.redis.RedisCache.*(..))")
+ public Object around(ProceedingJoinPoint point) throws Throwable {
+ Object result = null;
+ if(open){
+ try{
+ result = point.proceed();
+ }catch (Exception e){
+ logger.error("redis error", e);
+ throw new CustomException("Redis服务异常");
+ }
+ }
+ return result;
+ }
+}
+