【7.2.4】更新字典默认需要引用一个缓存

pull/34/head
fengshuonan 2022-08-01 21:53:05 +08:00
parent 562b5f2f1f
commit 180e4369c8
2 changed files with 5 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import cn.hutool.cache.impl.TimedCache;
import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants; import cn.stylefeng.roses.kernel.cache.api.constants.CacheConstants;
import cn.stylefeng.roses.kernel.cache.memory.operator.DefaultMemoryCacheOperator; import cn.stylefeng.roses.kernel.cache.memory.operator.DefaultMemoryCacheOperator;
import cn.stylefeng.roses.kernel.cache.memory.operator.DefaultStringMemoryCacheOperator; import cn.stylefeng.roses.kernel.cache.memory.operator.DefaultStringMemoryCacheOperator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -48,6 +49,7 @@ public class GunsMemoryCacheAutoConfiguration {
* @date 2021/1/31 20:39 * @date 2021/1/31 20:39
*/ */
@Bean @Bean
@ConditionalOnMissingBean(name = "defaultStringCacheOperator")
public DefaultStringMemoryCacheOperator defaultStringCacheOperator() { public DefaultStringMemoryCacheOperator defaultStringCacheOperator() {
TimedCache<String, String> stringTimedCache = CacheUtil.newTimedCache(CacheConstants.DEFAULT_CACHE_TIMEOUT); TimedCache<String, String> stringTimedCache = CacheUtil.newTimedCache(CacheConstants.DEFAULT_CACHE_TIMEOUT);
return new DefaultStringMemoryCacheOperator(stringTimedCache); return new DefaultStringMemoryCacheOperator(stringTimedCache);
@ -60,6 +62,7 @@ public class GunsMemoryCacheAutoConfiguration {
* @date 2021/1/31 20:39 * @date 2021/1/31 20:39
*/ */
@Bean @Bean
@ConditionalOnMissingBean(name = "defaultMemoryCacheOperator")
public DefaultMemoryCacheOperator defaultMemoryCacheOperator() { public DefaultMemoryCacheOperator defaultMemoryCacheOperator() {
TimedCache<String, Object> objectTimedCache = CacheUtil.newTimedCache(CacheConstants.DEFAULT_CACHE_TIMEOUT); TimedCache<String, Object> objectTimedCache = CacheUtil.newTimedCache(CacheConstants.DEFAULT_CACHE_TIMEOUT);
return new DefaultMemoryCacheOperator(objectTimedCache); return new DefaultMemoryCacheOperator(objectTimedCache);

View File

@ -70,10 +70,10 @@
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<!--缓存模块--> <!--缓存模块,默认依赖内存缓存实现-->
<dependency> <dependency>
<groupId>cn.stylefeng.roses</groupId> <groupId>cn.stylefeng.roses</groupId>
<artifactId>cache-api</artifactId> <artifactId>memory-cache-spring-boot-starter</artifactId>
<version>${roses.version}</version> <version>${roses.version}</version>
</dependency> </dependency>