我正在尝试从同一个类中调用一个 @Cacheable
方法:
@Cacheable(value = "defaultCache", key = "#id")
public Person findPerson(int id) {
return getSession().getPerson(id);
}
public List<Person> findPersons(int[] ids) {
List<Person> list = new ArrayList<Person>();
for (int id : ids) {
list.add(findPerson(id));
}
return list;
}
希望findPersons
的结果也被缓存,但是@Cacheable
注解被忽略了,findPerson
方法每次都被执行了。
我做错了什么吗?还是这是预期的结果?