`
@RestController
public class TestController {
@Cacheable(cacheNames = "testCache", key = "#name")
@GetMapping("/test/{name}")
public String test(@PathVariable String name) {
System.out.println("########Test Called ###### " + name);
return HttpStatus.OK.toString();
}
}
这里cacheNames是Stirng数组,如果name不存在于cacheNames中,那么它应该先添加,然后再执行其余的操作。
我使用的是spring Boot 缓存,必须根据请求参数添加cacheNames。
1条答案
按热度按时间qoefvg9y1#
如果您想要更大的灵活性,可以这样做:
在这种情况下,缓存名称将不是动态的,但该高速缓存键将是动态的。