为什么spring.cache.redis.key-prefix会覆盖@Cacheable(value =“ cacheValue”)

在我的application.yml中,我为我的缓存键定义了一个前缀:

spring:
  cache:
    redis:
      key-prefix: com.example.cache.

我还在@Cacheable批注中定义了一个缓存值。

@Repository
public interface UserRepository {
  @Cacheable(value = "users",key = "#criteria")
  List<User> findAllByCriteria(UserSearchCriteria critiera);
}

缓存用户后,我发现引用缓存用户列表的键是 com.example.cache.Criteria[],而不是com.example.cache.users::Criteria[]。 如果我遗漏了key-prefix,则密钥变成了users::Criteria[]

我对此行为感到非常困惑,如何将前缀和缓存值都保留在实际的Redis密钥中?

daming_110 回答:为什么spring.cache.redis.key-prefix会覆盖@Cacheable(value =“ cacheValue”)

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2863935.html

大家都在问