【8.3.3】【dict】【cache】初始化字典名称的缓存,key为复核类型

pull/62/head
stylefeng 2025-01-10 16:41:38 +08:00
parent 080760174a
commit 4e1bf45852
5 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package cn.stylefeng.roses.kernel.dict.modular.cache.dictnamemixed;
import cn.hutool.cache.impl.TimedCache;
import cn.stylefeng.roses.kernel.cache.memory.AbstractMemoryCacheOperator;
import cn.stylefeng.roses.kernel.dict.modular.constants.DictCacheConstants;
/**
*
* <p>
* keyvalue
* <p>
* key1. id+ 2. +
*
* @author fengshuonan
* @since 2025/1/10 16:33
*/
public class MixedDictNameMemoryCache extends AbstractMemoryCacheOperator<String> {
public MixedDictNameMemoryCache(TimedCache<String, String> timedCache) {
super(timedCache);
}
@Override
public String getCommonKeyPrefix() {
return DictCacheConstants.DICT_MIXED_NAME_CACHE_PREFIX;
}
}

View File

@ -0,0 +1,28 @@
package cn.stylefeng.roses.kernel.dict.modular.cache.dictnamemixed;
import cn.stylefeng.roses.kernel.cache.redis.AbstractRedisCacheOperator;
import cn.stylefeng.roses.kernel.dict.modular.constants.DictCacheConstants;
import org.springframework.data.redis.core.RedisTemplate;
/**
*
* <p>
* keyvalue
* <p>
* key1. id+ 2. +
*
* @author fengshuonan
* @since 2025/1/10 14:10
*/
public class MixedDictNameRedisCache extends AbstractRedisCacheOperator<String> {
public MixedDictNameRedisCache(RedisTemplate<String, String> redisTemplate) {
super(redisTemplate);
}
@Override
public String getCommonKeyPrefix() {
return DictCacheConstants.DICT_MIXED_NAME_CACHE_PREFIX;
}
}

View File

@ -37,4 +37,13 @@ public interface DictCacheConstants {
*/
String DICT_INFO_CACHE_PREFIX = "DICT:INFO:";
/**
*
* <p>
* keyvalue
* <p>
* key1. id+ 2. +
*/
String DICT_MIXED_NAME_CACHE_PREFIX = "DICT:MIXED:";
}

View File

@ -29,6 +29,7 @@ import cn.hutool.cache.impl.TimedCache;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
import cn.stylefeng.roses.kernel.dict.modular.cache.dictname.DictInfoMemoryCache;
import cn.stylefeng.roses.kernel.dict.modular.cache.dictnamemixed.MixedDictNameMemoryCache;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -55,4 +56,20 @@ public class DictMemoryCacheAutoConfiguration {
return new DictInfoMemoryCache(themeCache);
}
/**
* key
* <p>
* keyvalue
* <p>
* key1. id+ 2. +
*
* @author fengshuonan
* @since 2025/1/10 16:35
*/
@Bean
public CacheOperatorApi<String> dictNameMixedCache() {
TimedCache<String, String> themeCache = CacheUtil.newTimedCache(1000 * 3600L);
return new MixedDictNameMemoryCache(themeCache);
}
}

View File

@ -28,6 +28,7 @@ import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.cache.redis.util.CreateRedisTemplateUtil;
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
import cn.stylefeng.roses.kernel.dict.modular.cache.dictname.DictInfoRedisCache;
import cn.stylefeng.roses.kernel.dict.modular.cache.dictnamemixed.MixedDictNameRedisCache;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -56,4 +57,20 @@ public class DictRedisCacheAutoConfiguration {
return new DictInfoRedisCache(redisTemplate);
}
/**
* Redis
* <p>
* keyvalue
* <p>
* key1. id+ 2. +
*
* @author fengshuonan
* @since 2025/1/10 15:05
*/
@Bean
public CacheOperatorApi<String> dictNameMixedCache(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<String, String> redisTemplate = CreateRedisTemplateUtil.createObject(redisConnectionFactory);
return new MixedDictNameRedisCache(redisTemplate);
}
}