Skip to content

Instantly share code, notes, and snippets.

@sirech
Created May 8, 2022 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirech/7939d5916b35b2ac771f7ccd8f68ae6a to your computer and use it in GitHub Desktop.
Save sirech/7939d5916b35b2ac771f7ccd8f68ae6a to your computer and use it in GitHub Desktop.
static <R> Cache<String, R> cache(String name, MeterRegistry meterRegistry) {
Cache<String, R> cache = Caffeine.newBuilder()
.recordStats()
.expireAfterWrite(Duration.ofHours(24))
.maximumSize(6000)
.build();
CaffeineCacheMetrics.monitor(meterRegistry, cache, name);
return cache;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment