Redis快取切面,防止Redis當機影響正常業務邏輯
標題很清楚了,不說了
package com.raymon.hcp.security.aspect;
import com.raymon.hcp.security.annotation.CacheException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
/**
* Redis快取切面,防止Redis當機影響正常業務邏輯
* Created by zhanglei on 2020/3/17.
*/
@Aspect
@Component
@Order(2)
public class RedisCacheAspect {
private static Logger LOGGER = LoggerFactory.getLogger(RedisCacheAspect.class);
@Pointcut("execution(public * com.raymon.hcp.portal.service.*CacheService.*(..)) || execution(public * com.raymon.hcp.service.*CacheService.*(..))")
public void cacheAspect() {
}
@Around("cacheAspect()")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method method = methodSignature.getMethod();
Object result = null;
try {
result = joinPoint.proceed();
} catch (Throwable throwable) {
//有CacheException註解的方法需要丟擲異常
if (method.isAnnotationPresent(CacheException.class)) {
throw throwable;
} else {
LOGGER.error(throwable.getMessage());
}
}
return result;
}
}
相關文章
- 業務邏輯層快取應該設計快取
- Redis 快取失效機制Redis快取
- redis快取和業務應用瞭解Redis快取
- Redis快取穿透Redis快取穿透
- Redis 的快取淘汰機制(Eviction)Redis快取
- Redis快取穿透、快取雪崩、redis併發問題分析Redis快取穿透
- 快取工廠之Redis快取快取Redis
- 【Azure Redis 快取 Azure Cache For Redis】Redis連線池Redis快取
- redis實現文章投票邏輯Redis
- Redis快取擊穿、快取穿透、快取雪崩Redis快取穿透
- [Redis]快取穿透/快取擊穿/快取雪崩Redis快取穿透
- (四)Redis 快取應用、淘汰機制Redis快取
- 如何使用 Redis 快取Redis快取
- Laravel使用Redis快取LaravelRedis快取
- redis→分散式快取Redis分散式快取
- redis快取介紹Redis快取
- Redis快取篇(四)快取異常Redis快取
- Redis快取篇(一)Redis是如何工作的Redis快取
- Redis快取穿透和雪崩Redis快取穿透
- SmartSql Redis 分散式快取SQLRedis分散式快取
- redis快取優化案例Redis快取優化
- Redis快取穿透與雪崩Redis快取穿透
- redis快取架構概述Redis快取架構
- Redis快取php資料Redis快取PHP
- Redis當機恢復Redis
- 3.2.2的Model的快取邏輯快取
- unbound中快取時間邏輯快取
- 【Azure Redis 快取】Azure Redis功能性討論Redis快取
- Redis詳解(十二)------ 快取穿透、快取擊穿、快取雪崩Redis快取穿透
- 面試總結 —— Redis “快取穿透”、“快取擊穿”、“快取雪崩”面試Redis快取穿透
- Redis——快取穿透、快取擊穿、快取雪崩、分散式鎖Redis快取穿透分散式
- Redis快取穿透、快取雪崩、快取擊穿好好說說Redis快取穿透
- 什麼是redis快取雪崩、快取穿透、快取擊穿Redis快取穿透
- Django(39)使用redis配置快取DjangoRedis快取
- SpringBoot整合Redis快取Spring BootRedis快取
- Redis快取高可用叢集Redis快取
- Spring Boot Cache Redis快取Spring BootRedis快取
- redis 作為快取總結Redis快取