title: What is a right Spring Cache Configuration for Java Map and its values?
body: <p>I have next service that returns the whole map and a value by a key.</p>
  
  <pre><code>@Service
  @CacheConfig(cacheNames = "messages")
  public class MessageService {
  
      private final MessageRepository messageRepository;
  
      @Autowired
      public MessageService(MessageRepository messageRepository) {
          this.messageRepository = messageRepository;
      }
  
      @Cacheable
      public Map&lt;String, String&gt; findMessages() {
          return messageRepository.findAll();
      }
  
      @Cacheable(key = "#key")
      public String getMessage(String key) {
          return messageRepository.findByKey(key);
      }
  }
  </code></pre>
  
  <p>When <code>findMessages()</code> method will be invoked I want to save all the messages in cache. And when <code>getMessage(String key)</code> will be invoked it should return a value from the cache, but not from the repository. Is it possible to do it using Spring annotations? Currently it have separate cache entries for both of the methods. </p>