首页>代码>基于SpringBoot的轻量级Java快速开发平台>/X-SpringBoot/src/main/java/com/suke/czx/common/aspect/RedisAspect.java
package com.suke.czx.common.aspect;

import com.suke.czx.common.exception.RRException;
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.context.annotation.Configuration;

/**
 * Redis切面处理类
 *
 * @author czx
 * @email object_czx@163.com
 * @date 2017-07-17 23:30
 */
@Aspect
@Configuration
public class RedisAspect {
    private Logger logger = LoggerFactory.getLogger(getClass());
    //是否开启redis缓存  true开启   false关闭
    @Value("${spring.redis.open: false}")
    private boolean open;

    @Around("execution(* com.suke.czx.common.utils.RedisUtils.*(..))")
    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 RRException("Redis服务异常");
            }
        }
        return result;
    }
}
最近下载更多
最代码-宋家辉  LV61 2022年10月15日
王泽军  LV2 2022年8月26日
taijh999  LV13 2022年6月27日
cxdxfx12  LV14 2022年6月21日
2468867327  LV10 2022年5月18日
tangjj7260  LV18 2022年4月25日
glyph  LV10 2022年3月17日
xiaolin712  LV9 2022年3月8日
美丽的巨兔12138  LV7 2022年1月27日
wanglinddad  LV54 2021年9月1日
最近浏览更多
zolscy  LV12 4月9日
LHLHBBA 3月19日
暂无贡献等级
2771547747 3月6日
暂无贡献等级
ysugxx  LV9 2023年12月13日
Demo1111  LV30 2023年12月7日
lasttimeapp 2023年11月27日
暂无贡献等级
漫步的海星  LV4 2023年9月21日
skook7  LV2 2023年8月31日
tomcatllll  LV1 2023年6月27日
卡布琪洛  LV4 2023年5月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友