當前位置:成語大全網 - 書法字典 - spring中@cacheable的key是如何配置的?

spring中@cacheable的key是如何配置的?

值:緩存的名稱,在spring配置文件中定義。必須至少指定壹個。

例如:

@ cache able(value =“my cache“)或

@ cache able(value = {“cache 1“,“cache 2“}

關鍵:

緩存的鍵,可以為空。如果指定根據SpEL表達式編寫,如果未指定,則默認根據方法的所有參數進行組合。

例如:@ cache able(value =“test cache“,key =“# username“)

條件:

緩存的條件可以為空,用SpEL編寫,並返回true或false。只有當它為真時,才能執行緩存。

例如:@ cache able(value =“test cache“,condition =“# username。