SpringAop
Spring作为沉淀了许久的框架,在开发上带给的便利性不言而喻,主要是IOC+AOP关于这这两者的介绍请自行百度。看了AOP的实现:XML实现和注解实现,个人比较倾向于注解实现,不用写过多的配置比较方便。
Redis一种缓存技术提供了丰富的数据结构,下面就利用SpringAop+Redis实现热数据查询时首先在Redis中查询,不存在时再去数据库中查询。
注解实现
package com.luckincoffee.annoation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @description 注解
* @author Kangshuai Zuo
* @date 2019/1/5 14:54
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CheckFromRedisAnnotation {
// Redis命名空间
String domain() ;
// Redis中的key
String key();
}
package com.luckincoffee.aspect;
import com.luckinco