0
請參閱Spring Cache可用於緩存服務調用。如何使用具有兩個屬性的彈簧緩存作爲密鑰
特別在下面的XML片段:
<!-- the service we want to make cacheable -->
<bean id="bookService" class="x.y.service.DefaultBookService"/>
<!-- cache definitions -->
<cache:advice id="cacheAdvice" cache-manager="cacheManager">
<cache:caching cache="books">
<cache:cacheable method="findBook" key="#isbn"/>
<cache:cache-evict method="loadBooks" all-entries="true"/>
</cache:caching>
</cache:advice>
<!-- apply the cacheable behavior to all BookService interfaces -->
<aop:config>
<aop:advisor advice-ref="cacheAdvice" pointcut="execution(* x.y.BookService.*(..))"/>
</aop:config>
上述機制工作,如果關鍵是一個單一的財產。我需要基於isbn和作者進行緩存。
有人可以建議如何使用兩個屬性啓用緩存嗎?
感謝
謝謝。那很完美。 – kevin