簡而言之,當在方法上調用@CacheEvict時,如果找不到關鍵字,Gemfire會拋出EntryNotFoundException。Gemfire EntryNotFoundException for @CacheEvict
現在詳細地,
我有一個類
class Person {
String mobile;
int dept;
String name;
}
我有定義爲personRegion和personByDeptRegion 2個緩存區和所述服務是如下
@Service
class PersonServiceImpl {
@Cacheable(value = "personRegion")
public Person findByMobile(String mobile) {
return personRepository.findByMobile(mobile);
}
@Cacheable(value = "personByDeptRegion")
public List<Person> findByDept(int deptCode) {
return personRepository.findByDept(deptCode);
}
@Caching(
evict = { @CacheEvict(value = "personByDeptRegion", key="#p0.dept"},
put = { @CachePut(value = "personRegion",key = "#p0.mobile")}
)
public Person updatePerson(Person p1) {
return personRepository.save(p1);
}
}
當有一個調用updatePerson,並且如果personByDeptRegion中沒有條目,則會拋出一個異常,該異常表示關鍵字1的EntryNotFoundException(或者任何部分代碼) 。很有可能在調用@Cacheable方法之前調用此方法,並希望避免此異常。 有沒有什麼辦法可以調整Gemfire行爲,以便在給定區域不存在密鑰時正常返回? 另外,我也渴望知道是否有更好的實現上述使用Gemfire作爲緩存的場景。
春數據的GemFire:1.7.4
的GemFire版本:v8.2.1
注:上面的代碼僅用於表示的目的,我必須在實際工程中同一問題的多個服務。
哇!您應該考慮升級您的SDG版本! 1.3.5.RELEASE? o.O您意識到'1.8.4.RELEASE'是最新版本(基於GF 8.2.0)。 1.7.6.RELEASE是當前支持的維護版本(基於GF 8.1.0)。而且,SDG 1.9目前正在開發中,已有1.9個M1,預計將於12月12日推出1.9個GA。您可以通過查看SDG項目頁面(http://projects.spring.io/spring-data-gemfire/)... –
...以及查看項目兼容性矩陣Wiki頁面(https ://github.com/spring-projects/spring-data-gemfire/wiki/Spring-Data-GemFire-to-GemFire-Version-Compatibility)。此外,您可以在SD Wiki頁面上查看發佈詳情(https://github.com/spring-projects/spring-data-commons/wiki);請參閱右側的導航欄。當前版本是Gosling(SDG 1.7.6.RELEASE)和Hopper(SDG 1.8.4.RELEASE)。 Ingalls(https://github.com/spring-projects/spring-data-commons/wiki/Release-Train-Ingalls)即將上市。 –
說了這些......我將稍後跟進一個「回答」你的問題。 –