Cache Patterns in Java
This Java project demonstrates the implementation of Read/Write Through and Write Behind Cache Patterns using a distributed cache. These patterns are designed to enhance performance and efficiency in data access, optimizing Java applications for effective data retrieval and storage.
Key Features
- Read-Through Cache: Automatically loads data into the cache on a cache miss.
- Write-Through Cache: Immediately writes data to the data store and updates the cache.
- Write-Behind Cache: Writes data to the data store and updates the cache asynchronously.
Benefits
These caching strategies improve performance by reducing the number of calls to the data store and ensure data consistency between the cache and the data store. The Write-Behind pattern also reduces the risk of data loss with asynchronous data persistence.
Integration in Java Applications
This project showcases the use of advanced caching mechanisms within Java applications, focusing on enhancing data access performance and efficiency. They highlight the practical application and integration of these caching patterns in Java environments, without relying on JCache, to handle real-world data management challenges effectively.
Getting Started
Instructions for setting up the project can be found in the project's Repository. The setup includes prerequisites like JDK 17, an IDE, and Docker, along with steps for cloning the repository, building the project, and running tests.
Usage
The service, demonstrated through provided tests, additionally exposes a REST API documented with Swagger, making it ideal for exploring and manipulating data cache patterns.
Tech Stack of the Cache Patterns Project
The project leverages a robust stack of technologies and dependencies, ensuring optimal performance and scalability. Below is list of the technical stack.
Core Technologies
- Java JDK 17
- Spring Boot 3
- Hazelcast for Distributed Caching
- PostgreSQL as the Database System
- Liquibase for Database Migration
Spring Boot Dependencies
- Spring Boot Starter AOP
- Spring Boot Starter Actuator
- Spring Boot Starter Data JPA
- Spring Boot Starter Validation
- Spring Boot Starter Tomcat
- Spring Boot Starter Web
- Spring Boot Starter Cache
API Documentation and OpenAPI
- SpringFox Boot Starter
- Springdoc OpenAPI for WebMVC UI and UI
Observability and Monitoring
- Micrometer for Metrics and Prometheus Integration
Development Tools
- Project Lombok
- MapStruct for Object Mapping
- Spring Boot DevTools
Testing Dependencies
- Spring Boot Starter Test
- Junit Jupiter for Unit Testing
- AssertJ for Fluent Assertions
- Testcontainers for Integration Testing