@Cacheable key on multiple method arguments

后端 未结 6 2032
粉色の甜心
粉色の甜心 2020-11-30 18:36

From the spring documentation :

@Cacheable(value=\"bookCache\", key=\"isbn\")
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 18:51

    You can use a Spring-EL expression, for eg on JDK 1.7:

    @Cacheable(value="bookCache", key="T(java.util.Objects).hash(#p0,#p1, #p2)")
    

提交回复
热议问题