We have been using following code in production for quite some time now:
@Override
@Transactional(readOnly = true)
@Cacheable("WIDGET_SERVICE_CACHE")
public List<WidgetTO> findAllWidgets() {
return ...;
}
@Override
@Cacheable("WIDGET_SERVICE_CACHE")
@Transactional(readOnly = true)
public List<WidgetHostTO> findAllWidgetHosts() {
return ...;
}
As you can see these are 2 different zero-arg methods using the same cache. Now, after reading some documentation on Spring cache it would seem that the name of the method is not taken into account when putting elements in the cache.
What is unclear for us now is that although according to the documentation it should not work, it does. It does not appear that only the parameters are used for the key of the cache. If that's true, what else is taken into account. If not, how come it does work for us and does noet throw (ClassCast)Exceptions?