我正在尝试在Spring Boot应用程序中添加缓存。
以下是存储库方法:
@Cacheable(value = "booksByCategory", key = "#p0.categoryId", unless = "#result == null or #result.size()==0")
@EntityGraph(attributePaths = { "category" })
List<Book> findAllByCategoryId(Category category);
当List为EMPTY时,我不想缓存。 我在下面添加了:
unless = "#result == null or #result.size()==0""
,但不起作用。 如何在缓存时忽略/跳过空列表或空列表?