|
@@ -2,8 +2,9 @@
|
|
|
|
|
|
### 采用redis缓存
|
|
|
|
|
|
-#### 1.pom文件
|
|
|
-```java
|
|
|
+#### 1.pom.xml文件改动
|
|
|
+- 1、增加redis依赖
|
|
|
+```
|
|
|
<dependency>
|
|
|
<groupId>com.anji-plus</groupId>
|
|
|
<artifactId>spring-boot-gaea</artifactId>
|
|
@@ -16,10 +17,45 @@
|
|
|
</exclusions>
|
|
|
</dependency>
|
|
|
```
|
|
|
-删除exclusions内容,因为底层默认支持redis
|
|
|
-删除ehcache相关依赖
|
|
|
|
|
|
-#### 2.删除 package com.anjiplus.template.gaea.business.cache
|
|
|
+- 2、 删除ehcache相关依赖
|
|
|
+```
|
|
|
+ <dependency>
|
|
|
+ <groupId>net.sf.ehcache</groupId>
|
|
|
+ <artifactId>ehcache</artifactId>
|
|
|
+ <version>2.10.6</version>
|
|
|
+ </dependency>
|
|
|
+```
|
|
|
+
|
|
|
+
|
|
|
+#### 2.删除代码
|
|
|
+- 1、删除cache文件夹
|
|
|
+目录地址:com.anjiplus.template.gaea.business.cache
|
|
|
+
|
|
|
+- 2、删除相关bean
|
|
|
+文件地址:com.anjiplus.template.gaea.business.config.BusinessAutoConfiguration.java
|
|
|
+```
|
|
|
+ @Bean
|
|
|
+ public CacheHelper gaeaCacheHelper(){
|
|
|
+ return new ReportCacheHelper();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public EhCacheCache ehCacheCache() {
|
|
|
+ return (EhCacheCache) ehCacheCacheManager().getCache("reportCache");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建ehCacheCacheManager
|
|
|
+ */
|
|
|
+ @Bean
|
|
|
+ public EhCacheCacheManager ehCacheCacheManager() {
|
|
|
+
|
|
|
+ return new EhCacheCacheManager();
|
|
|
+ }
|
|
|
+```
|
|
|
+
|
|
|
+底层的实现方式如下:
|
|
|
CacheHelper底层默认实现为RedisCacheHelper。
|
|
|
@ConditionalOnMissingBean 注解起到的作用
|
|
|
```java
|
|
@@ -37,5 +73,13 @@ public class GaeaAutoConfiguration {
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-#### 3.bootstrap.yml加上对应的redis配置即可
|
|
|
+#### 3.bootstrap.yml加上对应的redis配置
|
|
|
+注意yml格式
|
|
|
+```
|
|
|
+# redis:
|
|
|
+# host: 127.0.0.1
|
|
|
+# port: 6379
|
|
|
+# password: root
|
|
|
+# database: 1
|
|
|
|
|
|
+```
|