Skip to content

Commit

Permalink
implement code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Dec 26, 2024
1 parent f2f6719 commit 4dacbf4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
7 changes: 3 additions & 4 deletions boot-ultimate-redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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/)

2 changes: 2 additions & 0 deletions graphql/boot-graphql-webflux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down
40 changes: 33 additions & 7 deletions jpa/boot-hibernate2ndlevelcache-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<!-- TOC -->
* [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)
<!-- TOC -->

---

### 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:

Expand All @@ -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.

Expand All @@ -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<Employee> employees;
}
```

0 comments on commit 4dacbf4

Please sign in to comment.