08-02-2023, 11:11 AM
I'm trying to call a `@Cacheable` method from within the same class:
@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;
}
and hoping that the results from `findPersons` are cached as well, but the `@Cacheable` annotation is ignored, and `findPerson` method got executed everytime.
Am I doing something wrong here, or this is intended?
@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;
}
and hoping that the results from `findPersons` are cached as well, but the `@Cacheable` annotation is ignored, and `findPerson` method got executed everytime.
Am I doing something wrong here, or this is intended?