From 4dacbf42164beb95b228f3cedcecc9ec99037104 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Thu, 26 Dec 2024 13:32:24 +0000 Subject: [PATCH] implement code review comments --- boot-ultimate-redis/README.md | 7 ++-- graphql/boot-graphql-webflux/README.md | 2 + .../README.md | 40 +++++++++++++++---- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/boot-ultimate-redis/README.md b/boot-ultimate-redis/README.md index 4d2a33ba0..97aa8523c 100644 --- a/boot-ultimate-redis/README.md +++ b/boot-ultimate-redis/README.md @@ -9,8 +9,6 @@ A comprehensive sample showcasing various Redis usage patterns, including sentin - Runs 1 master, 1 replica, and 3 sentinel instances via Docker Compose. - **Quorum** Setting (defaults to 2) for failover decisions. -## ReadFrom Settings - ## ReadFrom Settings Configurable with Lettuce through application properties: @@ -90,6 +88,7 @@ We will run 1 master,1 slave and 3 sentinel instance. We are using _REPLICA_PREFERRED_ in here but this configuration can be important in production! ### Reference - - [medium](https://medium.com/@htyesilyurt/spring-boot-3-redis-sentinel-lettuce-client-and-docker-compose-for-high-availability-1f1e3c372a5a) - - [programmerfriend](https://programmerfriend.com/ultimate-guide-to-redis-cache-with-spring-boot-2-and-spring-data-redis/) + ### Reference + - [Spring Boot 3 Redis Sentinel Guide](https://medium.com/@htyesilyurt/spring-boot-3-redis-sentinel-lettuce-client-and-docker-compose-for-high-availability-1f1e3c372a5a) + - [Ultimate Guide to Redis Cache](https://programmerfriend.com/ultimate-guide-to-redis-cache-with-spring-boot-2-and-spring-data-redis/) \ No newline at end of file diff --git a/graphql/boot-graphql-webflux/README.md b/graphql/boot-graphql-webflux/README.md index ad662009f..89cb48850 100644 --- a/graphql/boot-graphql-webflux/README.md +++ b/graphql/boot-graphql-webflux/README.md @@ -8,6 +8,8 @@ Implements a reactive GraphQL server using Spring WebFlux, enabling highly scala - **Reactive Execution**: Non-blocking data fetchers. - **Scalable**: Ideal for high-concurrency scenarios. +- **Performance**: Handles thousands of concurrent requests with minimal overhead. +- **Memory Efficient**: Reduces memory footprint through backpressure handling. --- diff --git a/jpa/boot-hibernate2ndlevelcache-sample/README.md b/jpa/boot-hibernate2ndlevelcache-sample/README.md index 76b52b618..911c8d4b5 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/README.md +++ b/jpa/boot-hibernate2ndlevelcache-sample/README.md @@ -8,22 +8,37 @@ Leverages Redis to cache frequently accessed entities and associations for faster read performance, reducing round-trips to the database. +> **Compatibility Note**: This implementation has been tested with Redis version 7.4.1 and above. + +--- +## Table of Contents + +* [Hibernate 2nd Level Cache with Redis](#hibernate-2nd-level-cache-with-redis) + * [Run tests](#run-tests) + * [Run locally](#run-locally) + * [Using Testcontainers at Development Time](#using-testcontainers-at-development-time) + * [Useful Links](#useful-links) + * [Notes](#notes) + * [**Caching Collections (One-Many & Many-Many Relations)**](#caching-collections-one-many--many-many-relations) + * [Example Configuration](#example-configuration) + + --- -### Run tests +## Run tests ```shell ./mvnw clean verify ``` -### Run locally +## Run locally ```shell docker-compose -f docker/docker-compose.yml up -d ./mvnw spring-boot:run -Dspring-boot.run.profiles=local ``` -### Using Testcontainers at Development Time +## Using Testcontainers at Development Time You can run `TestApplication.java` from your IDE directly. You can also run the application using Maven as follows: @@ -32,18 +47,18 @@ You can also run the application using Maven as follows: ``` -### Useful Links +## Useful Links * Swagger UI: http://localhost:8080/swagger-ui.html * Actuator Endpoint: http://localhost:8080/actuator +--- -### Notes +## Notes * We need to explicitly set the querycacheHint to customerqueries for enabling 2nd level cache * This is enabled only for SessionFactory(i.e as soon as application is closed it will be deleted) -### **Caching Collections (One-Many & Many-Many Relations)** - +## **Caching Collections (One-Many & Many-Many Relations)** Collection caching allows you to cache entire collections of associated entities. These collections can be part of your domain model, such as one-to-many or many-to-many relationships between entities. @@ -53,3 +68,14 @@ When Hibernate caches a collection, it doesn’t cache the entire collection of * Caching only the IDs reduces memory usage compared to caching the entire collection of entities. * When a collection is updated, only the relevant IDs need to be invalidated in the cache, rather than the entire collection. This minimizes cache invalidation overhead. + +### Example Configuration + +```java +@Entity +public class Department { + @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) + @OneToMany(mappedBy = "department") + private List employees; +} +```