mirror of https://gitee.com/stylefeng/roses
【8.3.3】【dict】【cache】初始化字典名称的缓存,key为复核类型
parent
080760174a
commit
4e1bf45852
|
@ -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>
|
||||
* key是混合类型的,value是字典名称
|
||||
* <p>
|
||||
* key可能有两种,1. 字典类型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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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>
|
||||
* key是混合类型的,value是字典名称
|
||||
* <p>
|
||||
* key可能有两种,1. 字典类型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;
|
||||
}
|
||||
|
||||
}
|
|
@ -37,4 +37,13 @@ public interface DictCacheConstants {
|
|||
*/
|
||||
String DICT_INFO_CACHE_PREFIX = "DICT:INFO:";
|
||||
|
||||
/**
|
||||
* 字典名称的缓存
|
||||
* <p>
|
||||
* key是混合类型的,value是字典名称
|
||||
* <p>
|
||||
* key可能有两种,1. 字典类型id+字典编码 2. 字典类型编码+字典编码
|
||||
*/
|
||||
String DICT_MIXED_NAME_CACHE_PREFIX = "DICT:MIXED:";
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
* key是混合类型的,value是字典名称
|
||||
* <p>
|
||||
* key可能有两种,1. 字典类型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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
* key是混合类型的,value是字典名称
|
||||
* <p>
|
||||
* key可能有两种,1. 字典类型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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue