Skip to content

Instantly share code, notes, and snippets.

@eisenjulian
Created October 7, 2016 18:05
Show Gist options
  • Save eisenjulian/b4553d1381c96b15457b2eb664bcc618 to your computer and use it in GitHub Desktop.
Save eisenjulian/b4553d1381c96b15457b2eb664bcc618 to your computer and use it in GitHub Desktop.
private <T> Optional<T> redisApply(final BiFunction<Jedis, Boolean, T> callback) {
final List<T> result = new ArrayList<>();
new RetryingHandler().tryClosure((redisServer, results, loggingActivated, isProductionEnvironment) -> {
try (final Jedis jedis = redisServer.getPool().getResource()) {
result.add(callback.apply(jedis, isProductionEnvironment));
}
}, null);
return result.stream().findFirst();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment