I am well aware that there are multiple questions on this topic, but I just can't get the sense of it. The problem seems to be that @CachePut does not add the new value to the @Cacheable list.
After debugging the problem I found out that the problem seems to be in the key.
Here is the code snippet
@CacheConfig(cacheNames = "documents")
interface DocumentRepository {
@CachePut(key = "#a0.id")
Document save(Document document);
@Cacheable()
List<Document> findAll();
}
So when I invoke the save method, the key being used for caching is incrementing integer, or 1,2,3... But when I try to get all documents, the cache uses SimpleKey[] as key. If I try to use the same key for @Cacheable, I get SpelEvaluationException, property 'id' cannot be found on null.
So what I am left with at the end is functional cache (the data is saved in the cache), but somehow I am not able to retrieve it. The underlying cache implementation is EhCache.