Example of object caching in Redis for Spring Boot applications
The application is designed as an internal microservice with no public access to it and no user interface.
Data is passed to the service via a POST request. The data can then be read via a GET request. In the current version, the service does not provide a method to remove data from Redis - this is the intention.
It is also expected that the data must be signed. In our simplified case, the signature is a string in the format “key: value”, for example, you can use “login:password” or anything you choose.
Java
- version21
Maven
- for building the applicationJackson
- for working with JSONSpring Boot
- version3.4.3
Spring Cloud
- version2023.0.3
Spring Boot Actuator
- it's for real-world applicationsDocker
- containerizationDocker-Compose
- infrastructure
spring-boot-with-redis-in-action/
├── compose.yml # docker-compose file
├── src/main/
| ├── java/com/dudko/example
| | ├── config/
| | ├── controller/ # domain level of requests and controllers
| | ├── domain/ # persistent domain level and repositories
| | ├── model/ # service level of the domain, used in business logic
| | ├── service/ # business logic
| ├── resources/ # configs
├── pom.xml # artifact of Maven
├── postman_collection.json # collection of requests for Postman
docker-compose -f compose.yml up
Anatoly Dudko