I have the following for the usage of a @Cacheable in spring (3.1):
spring:
In my case, the problem was caused by using the wrong configuration of the cache provider (Caffeine):
@Bean
public Caffeine
As the docs says, weakKeys() method:
Specifies that each key (not value) stored in the cache should be wrapped in a WeakReference (by default, strong references are used).
Warning: when this method is used, the resulting cache will use identity ({@code ==}) comparison to determine equality of keys. Its {@link Cache#asMap} view will therefore technically violate the {@link Map} specification (in the same way that {@link IdentityHashMap} does).