0

We are using Lettuce java client to connect to AWS Elasticache (Valkey engine, Serverless, version 8.0) from Java springboot application (JDK 17 & springboot version 3.2.5)

Below is the method where I am trying to write multiple keys into elasticache using jsonMSet().

public void setJsonObjects(List<Details> details, long ttl) {
 cacheConnectionPool.thenCompose(connectionPool -> {
 try {
 StatefulRedisConnection<String, String> connection = connectionPool.acquire().get();
 RedisAsyncCommands<String, String> async = connection.async();
 
 async.jsonMSet(createJsonMsetArgs(details, async));
 return async.exec().whenComplete((s, throwable) -> connectionPool.release(connection));
 } catch (Exception e) {
 log.warn("Exception while writing to Cache: {}", e.getMessage());
 return null;
 }
 });
}
public List<JsonMsetArgs<String, String>> createJsonMsetArgs(List<Details> details,
 RedisAsyncCommands<String, String> async) {
 List<JsonMsetArgs<String, String>> msetList = new ArrayList<>();
 if (details != null && !details.isEmpty()) {
 details.forEach(detail -> {
 JsonMsetArgs<String, String> msetArg = new JsonMsetArgs<String, String>(
 String.format(KEY_FORMAT, detail.getId()),
 JsonPath.ROOT_PATH,
 async.getJsonParser().fromObject(detail));
 msetList.add(msetArg);
 });
 }
 return msetList;
}

Code executes fine without any errors or warnings. But nothing is being written into elasticache. The new cache Keys are not appearing in cache.

Could you please advise what is going wrong here ?

Regards, Alex

asked Jun 30 at 12:01

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.