-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
GangCheng
committed
Aug 18, 2023
1 parent
aeb0d34
commit 8ebc644
Showing
1 changed file
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,84 @@ | ||
# reactive-cache-support | ||
reactive-cache-support | ||
# Reactive Cache Support | ||
|
||
[![Java CI with Maven](https://github.com/chenggangpro/reactive-cache-support/actions/workflows/maven-ci.yml/badge.svg?branch=develop)](https://github.com/chenggangpro/reactive-cache-support/actions/workflows/maven-ci.yml) | ||
[![Coverage](.github/badges/jacoco.svg)](https://github.com/chenggangpro/reactive-cache-support/actions/workflows/maven-ci.yml) | ||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
|
||
#### This project is supposed to implement the general reactive cache operation approach. | ||
|
||
#### Introduction | ||
|
||
* This project is compatible with `reactivestream` aka [`project-reactor`](https://projectreactor.io/) | ||
* This project could integrate with `Spring Framework` (version>= 2.x) | ||
* This project implement reactive cache for business application scenarios. The default implementation includes the following: | ||
* `InmemeoryReactiveCache` uses `java.util.DelayQueue` to implement cache behavior | ||
* `RedisReactiveCache` uses `redis` and `spring-boot-redis` to implement cache behavior | ||
* `DefaultReactiveCache` uses customized configuration to implement cache behavior | ||
|
||
#### Usage | ||
|
||
* Standalone usages | ||
|
||
> InmemoryReactiveCache | ||
```java | ||
ReactiveCacheManager reactiveCacheManager = ReactiveCacheManagerBuilder.newInmemoryReactiveManagerBuilder() | ||
.withMaxWaitingDuration(Duration.ofSeconds(5)) | ||
.withInmemoryReactiveCacheLock() | ||
.build(); | ||
``` | ||
|
||
> RedisReactiveCache | ||
```java | ||
ReactiveCacheManager reactiveCacheManager = ReactiveCacheManagerBuilder.newRedisReactiveManagerBuilder( | ||
reactiveRedisTemplate) | ||
.withMaxWaitingDuration(Duration.ofSeconds(5)) | ||
.withRedisReactiveCacheLock() | ||
.build(); | ||
``` | ||
|
||
> Customized ReactiveCache | ||
```java | ||
ReactiveCacheManager reactiveCacheManager = ReactiveCacheManagerBuilder.newCustomReactiveManagerBuilder() | ||
.withMaxWaitingDuration(Duration.ofSeconds(5)) | ||
// Customized ReactiveCacheLock instance implemented interface ReactiveCacheLock | ||
.withReactiveCacheLock() | ||
// Customized ReactiveCacheMonoAdapter instance implemented interface ReactiveCacheMonoAdapter | ||
.withReactiveCacheMonoAdapter() | ||
// Customized ReactiveCacheFluxAdapter instance implemented interface ReactiveCacheFluxAdapter | ||
.withReactiveCacheFluxAdapter() | ||
.build(); | ||
``` | ||
|
||
* SpringBoot usages | ||
|
||
* Configuration properties as: | ||
|
||
```yaml | ||
reactive: | ||
cache: | ||
enabled: true | ||
type: inmemory | ||
``` | ||
|
||
* Using with spring auto-injection | ||
|
||
```java | ||
@Autowired | ||
ReactiveCacheManager reactiveCacheManager; | ||
``` | ||
|
||
* For more details, please refer to the source code and the test cases. | ||
|
||
#### Note: | ||
|
||
* Test cases run with `testcontainers`, so please ensure that you have access to `Docker` in your local environment. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|