我想知道是否可以在 spring 数据 mongo 存储库上使用 @Cacheable 注释。例如像这样:
public interface UserRepository extends MongoRepository<User, String> {
@Cacheable("byId")
public interface UserRepository extends MongoRepository<User, String> {
User findById(String id);
}
}
我想在接口类本身上做,如果可能的话避免使用包装类。此外,是否有关于如何使用 java config(不是 xml)为 redis 进行缓存配置的示例?