feat: 增加 spring cache 开关配置,默认关闭
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.youlai.system.config;
|
package com.youlai.system.config;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.cache.CacheProperties;
|
import org.springframework.boot.autoconfigure.cache.CacheProperties;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -21,6 +22,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
|
|||||||
@EnableCaching
|
@EnableCaching
|
||||||
@EnableConfigurationProperties(CacheProperties.class)
|
@EnableConfigurationProperties(CacheProperties.class)
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ConditionalOnProperty(name = "spring.cache.enabled") // xxl.job.enabled = true 才会自动装配
|
||||||
public class RedisCacheConfig {
|
public class RedisCacheConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ spring:
|
|||||||
# 连接池中的最小空闲连接 默认0
|
# 连接池中的最小空闲连接 默认0
|
||||||
min-idle: 0
|
min-idle: 0
|
||||||
cache:
|
cache:
|
||||||
|
enabled: false
|
||||||
# 缓存类型 redis、none(不使用缓存)
|
# 缓存类型 redis、none(不使用缓存)
|
||||||
type: redis
|
type: redis
|
||||||
# 缓存时间(单位:ms)
|
# 缓存时间(单位:ms)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ spring:
|
|||||||
# 连接池中的最小空闲连接 默认0
|
# 连接池中的最小空闲连接 默认0
|
||||||
min-idle: 0
|
min-idle: 0
|
||||||
cache:
|
cache:
|
||||||
|
enabled: false
|
||||||
# 缓存类型 redis、none(不使用缓存)
|
# 缓存类型 redis、none(不使用缓存)
|
||||||
type: redis
|
type: redis
|
||||||
# 缓存时间(单位:ms)
|
# 缓存时间(单位:ms)
|
||||||
|
|||||||
Reference in New Issue
Block a user