0
我正在使用Spring
以及使用@Cacheable
和@CachePut
註釋的內置高速緩存。Spring @CachePut將兩個鍵的值相同
我在我的@Service中有2個方法,一個用於保存數據庫中的值,第二個用於從數據庫中獲取值。他們兩人都使用緩存。
@CachePut(key = "#code")
MyObject saveMyObject(MyObject o, String code) {
return dao.save(o);
}
@Cacheable(key = "#code")
MyObject getMyObject(String code) {
return dao.getMyObject(code);
}
在保存對象時,我想把它放在另一個緩存中,例如
@CachePut(key = "'TMP_'.concat(#code)")
,但我不能saveMyObject
方法使用兩個@CachePut
註解。
我該怎麼辦?
真棒,不知道緩存註解! – user3626048