Skip to content

No exception thrown from Jedis when AWS Elasticache instance is out of memory #2813

Answered by kalimatas
kalimatas asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

Thanks for the hint: indeed, there are failed responses which we can extract and check. Here how it works:

Iterators.partition(someiterator(), batchSize)
    .forEachRemaining(batch -> {
        try (var jedis = jedisPool.getResource()) {
            var pipe = jedis.pipelined();
            batch.forEach(entry -> {   pipe.set(someKey, someValue);  });
            failOnResponseError(pipe.syncAndReturnAll());
         }
    });

static void failOnResponseError(final List<Object> redisResponses) {
        for (var response : redisResponses) {
            if (response instanceof JedisException ex) {
                throw ex;
            }
        }
    }

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@kalimatas
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by kalimatas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants