forked from shaikezr/async-cacheable
-
Notifications
You must be signed in to change notification settings - Fork 0
vmptk/async-cacheable
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
#@AsyncCacheable ##Overview: Caching annotation used to cache Mono/Flux values. Uses an async loading cache to offer resilience to cache stampedes. Converts Mono/Flux to CompleteableFuture prior to upserting into the cache, and converts from CompleteableFuture back to Mono/Flux after retrieval from the cache. ##Usage: Simply annotate a function returning Mono/Flux with `@AsyncCacheable`. ##Parameters: Each cache instance is a hash of it's parameters. Annotations with the same parameters will use the same cache. Annotations with different parameters will use different caches. The parameters are: ``` name: String, a name for the cache. Default name is "default1000Item5MinuteCache" maximumSize: Long, maximum number of items in the cache. Default maximumSize is 1000 expireAfterWriteSeconds: Long, number of seconds after writing to the cache to expire items. Default is 300``` These parameters can be overridden by specifying the value you want in your annotation invocation. Ex: ``` @AsyncCacheable public Mono<String> myCachedMono() { System.out.println("Uncached response"); return Mono.just("hi"); } public Mono<String> myUnCachedMono() { System.out.println("Uncached response"); return Mono.just("hey"); } @AsyncCacheable(name="customName", maximumSize=100L, expireAfterWriteSeconds=50L) public Mono<String> myCustomCachedMono() { System.out.println("Uncached response"); return Mono.just("hey"); }``` ##Acknowledgements: ben-manes/caffeine#500 https://gist.github.com/bijukunjummen/a12ab5d3e823c5f052ce608b5fc7b6a4
About
Fleshed out Async Caching solution for Spring + Mono/Flux
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Java 82.1%
- Kotlin 17.9%