title: Spring Webflux and @Cacheable - proper way of caching result of Mono / Flux type
body: <p>I'm learning Spring WebFlux and during writing a sample application I found a concern related to Reactive types (Mono/Flux) combined with Spring Cache.</p>
  
  <p>Consider the following code-snippet (in Kotlin):</p>
  
  <pre><code>@Repository
  interface TaskRepository : ReactiveMongoRepository&lt;Task, String&gt;
  
  @Service
  class TaskService(val taskRepository: TaskRepository) {
  
      @Cacheable("tasks")
      fun get(id: String): Mono&lt;Task&gt; = taskRepository.findById(id)
  }
  </code></pre>
  
  <p>Is this valid and safe way of caching method calls returning Mono or Flux? Maybe there are some other principles to do this?</p>
  
  <p>The following code is working with SimpleCacheResolver but by default fails with Redis because of the fact that Mono is not Serializable. In order to make them work e.g Kryo serializer needs to be used.</p>