多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
**1. 定义key生成器** ```java @Configuration public class CustomCacheConfig { @Bean("myKeyGenerator") public KeyGenerator keyGenerator() { return new KeyGenerator() { @Override public Object generate(Object target, Method method, Object... params) { //返回的字符串就是key return method.getName() + "[" + Arrays.asList(params).toString() + "]"; } }; } } ``` <br/> **2. 注解中使用自定义key生成器** ```java @Slf4j @Service public class StudentServiceImpl implements StudentService { @Cacheable(value = {"student"}, keyGenerator = "myKeyGenerator") public Student find(Integer id) { Student student = new Student(id, "张三", 25); return student; } } ```