# easy-dict **Repository Path**: xiwenlu/easy-dict ## Basic Information - **Project Name**: easy-dict - **Description**: java 字典翻译 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-19 - **Last Updated**: 2025-09-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 添加Maven依赖 ```xml io.gitee.xiwenlu easy-dict 1.0.0 ``` [仓库地址](https://gitee.com/xiwenlu/easy-dict) # 和redis整合实现字典缓冲 1. pom添加 ```xml org.springframework.boot spring-boot-starter-data-redis ``` 2. yml添加缓冲相关配置 ```yml spring: data: redis: host: 127.0.0.1 port: 6379 database: 1 timeout: 10s cache: type: redis redis: time-to-live: 3600s cache-names: dict,dictList ``` 3. 启动类添加注解`@EnableCaching` 4. 实现`DictProvider`接口 ```java @Service @Slf4j public class DictDataServiceImpl extends ServiceImpl implements IDictDataService, DictProvider { @Resource private RoleMapper roleMapper; @Override @Cacheable(value = "dict", key = "#typeCode + '-' + #value") public String getDictName(String typeCode, String value) { log.info("输入的typeCode={},value={}",typeCode,value); if (value == null){ return null; } // 自定义其他调用 if (typeCode.equals("role_code")){ return roleMapper.getDictName(value); } return this.baseMapper.getDictName(typeCode,value); } @Cacheable(value = "dictList", key = "#typeCode") public List getDictListByTypeCode(String typeCode) { return this.list(Wrappers.lambdaQuery().eq(DictData::getTypeCode, typeCode).orderByAsc(DictData::getSort)); } } ```