Refresh your Cache before it expires!
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
checkstyle
src/main
.gitignore
LICENSE
README.md
pom.xml

README.md

Maven Central Javadocs Project Stats

[Unit Tests CircleCI [Integration Tests CircleCI

[SonarQube]

Cache Refresh Ahead Starter

A Cache Refresh-Ahead Spring Boot Starter for Caffeine and Redis cache!

This starter enables Refresh-Ahead Caching. This enables clients to benefit from the speed of caching while the application keeps the cache closely up-to-date. The client will not feel any impact of the slow source behind the cache.

Supported Cache Frameworks

Currently, only Caffeine and Redis Cache is supported.

Usage

Examples

You can find examples of how to use the library at https://github.com/SvenBayer/cache-refresh-ahead-samples

Preprequisites

You have to add @EnableCaching to your project and define a CacheManager bean.

Setup

Add the Spring Boot starter to your maven pom. Define the expiration of your cache values.

Define the cache refresh intervals in your application.properties/yml. You can either define a global interval, or specify an interval for each cache separately. For example, the first line specifies that the caches are reloaded every 5 seconds. The second line specifies that only the cache named longrun is being reloaded every 5 seconds.

cache.reload.ahead.refresh-ahead-interval=5s
cache.reload.ahead.refresh-ahead-interval-caches.longrun=5s

More Information

Visit my blog at https://svenbayer.blog