This is a CRUD API built with Spring Boot that integrates Redis for caching and PostgreSQL as the primary database. The API allows creating, reading, updating, and deleting records with caching enabled to enhance performance. Redis is used to cache frequently accessed data, reducing load on the PostgreSQL database.
- CRUD Operations with Redis caching for enhanced performance
- Integration with PostgreSQL for persistent storage
- Spring Data JPA for database operations
- Spring Cache abstraction for Redis integration
- RESTful API design with clean architecture
- Input validation and error handling
- Swagger UI for API documentation and testing
- Spring Boot 2.5.4
- Redis for caching
- PostgreSQL as the primary database
- Spring Data JPA for database interaction
- Lombok for reducing boilerplate code
- Swagger for API documentation
api-springboot-redis/
│
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/redis/ # Source code and main application
│ ├── resources/
│ │ ├── application.properties # Configuration for PostgreSQL, Redis
│ └── test/
│ └── java/ # Unit tests for services and controllers
└── pom.xml # Project dependencies
-
Clone the repository
git clone https://github.com/mochrks/api-springboot-redis.git cd api-springboot-redis
-
Install dependencies
mvn clean install
-
Set up PostgreSQL and Redis
-
Ensure PostgreSQL and Redis are running locally or provide your connection strings in
application.properties
. -
For PostgreSQL, update the following properties in
src/main/resources/application.properties
:spring.datasource.url=jdbc:postgresql://localhost:5432/yourdbname spring.datasource.username=yourusername spring.datasource.password=yourpassword
-
For Redis, update the following properties:
spring.redis.host=localhost spring.redis.port=6379
-
-
Run the application
mvn spring-boot:run