Skip to content

Instantly share code, notes, and snippets.

@nattaphonjeamjit
Last active June 16, 2018 03:39
Show Gist options
  • Save nattaphonjeamjit/84c2ff2a999752f6325bcd6476971a72 to your computer and use it in GitHub Desktop.
Save nattaphonjeamjit/84c2ff2a999752f6325bcd6476971a72 to your computer and use it in GitHub Desktop.
@Override
public void savePaymentStatus(String paymentId, AcquiringResponse.PaymentStatus paymentStatus) {
pmcRedisTemplate.execute(new SessionCallback<Void>(){
@Override
public Void execute(RedisOperations operations) throws DataAccessException {
operations.watch(paymentId);
if (!findPaymentStatusByPaymentId(paymentId).isPresent()) {
operations.multi();
updatePaymentStatus(paymentId, paymentStatus.getValue());
operations.exec();
logger.debug("Saving status {} of payment id {} success", paymentStatus.getValue(), paymentId);
} else {
logger.debug("Payment id {} is already in redis", paymentId);
}
return null;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment