Spring如何存储缓存和Redis的密钥

Spring如何存储缓存和Redis的密钥,redis,spring-cache,Redis,Spring Cache,我按照web上的一些教程使用redis设置Spring Cache 我的函数如下所示: @Cacheable(value=“post single”,key=“#id”,除非=“#result.shares

我按照web上的一些教程使用redis设置Spring Cache

我的函数如下所示:

@Cacheable(value=“post single”,key=“#id”,除非=“#result.shares<500”)
@GetMapping(“/{id}”)
public Post getPostByID(@PathVariable String id)引发PostNotFoundException{
info(“获取id为{},id为的帖子”);
return postService.getPostByID(id);
}
据我所知,
@Cacheable
中的值是缓存名称,
key
是该缓存名称中的缓存键。我还知道Redis是一个内存中的键/值存储。但现在我对Spring将如何将
缓存名称
存储到Redis感到困惑,因为看起来Redis只管理键和值,而不是缓存名称

寻找任何能向我解释的人


提前感谢

Spring在存储数据时使用
缓存名称
作为密钥前缀。例如,当您使用
id=1
调用端点时,您将在Redis中看到此键

post-single::1

您可以通过
CacheKeyPrefix
类自定义前缀格式。

谢谢@Aleh我在这里还找到了如何配置缓存键前缀