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/a3d862077f512b5e4a34916deaefc816 to your computer and use it in GitHub Desktop.
Save sirech/a3d862077f512b5e4a34916deaefc816 to your computer and use it in GitHub Desktop.
public T get(Supplier<String> keySupplier, Supplier<R> valueSupplier) {
Supplier<T> decoratedSupplier = Decorators.ofSupplier(() -> getAndCache(key, valueSupplier))
.withRetry(retry)
.withCircuitBreaker(cb).decorate();
var key = keySupplier.get();
return Try.ofSupplier(decoratedSupplier)
.recover(RuntimeException.class, (exception) -> getFromCacheOrThrow(key, exception))
.get();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment