-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : update Cache Asynchronously (#1387)
* feat : adds negative tests and labels * feat : update cache asynchronously * update cache always asynchronously * fix : issue with deleting all
- Loading branch information
1 parent
570187b
commit 65bb377
Showing
5 changed files
with
76 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
r2dbc/boot-reactive-cache/src/main/java/com/example/cache/config/Initializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
package com.example.cache.config; | ||
|
||
import com.example.cache.entities.Movie; | ||
import com.example.cache.repositories.MovieRepository; | ||
import com.example.cache.services.MovieService; | ||
import com.example.cache.utils.AppConstants; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@Profile(AppConstants.PROFILE_NOT_TEST) | ||
class Initializer { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(Initializer.class); | ||
|
||
@Bean | ||
public ApplicationRunner saveMovies(MovieRepository repository) { | ||
public ApplicationRunner saveMovies(MovieService movieService) { | ||
Flux<Movie> movies = Flux.just( | ||
new Movie(null, "DJ Tillu"), | ||
new Movie(null, "Tillu Square"), | ||
new Movie(null, " Om Bheem Bush"), | ||
new Movie(null, "Aa Okkati Adakku"), | ||
new Movie(null, " Bhimaa")); | ||
return args -> repository | ||
return args -> movieService | ||
.deleteAll() | ||
.thenMany(repository.saveAll(movies)) | ||
.thenMany(movieService.saveAllMovies(movies)) | ||
.subscribe(movie -> log.info(movie.toString())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters