jdeppe-pivotal commented on a change in pull request #6862:
URL: https://github.com/apache/geode/pull/6862#discussion_r713037913
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
##########
@@ -172,6 +176,42 @@ public RedisStats getRedisStats() {
}
}
+ /**
+ * Execute the given Callable in the context of a GemFire transaction. On
failure there is no
+ * attempt to retry.
+ */
+ public <T> T executeInTransaction(RedisKey key, Callable<T> callable) {
+ Callable<T> txWrappedCallable = getTxWrappedCallable(callable);
+ return execute(key, txWrappedCallable);
+ }
+
+ /**
+ * Execute the given Callable in the context of a GemFire transaction. On
failure there is no
+ * attempt to retry.
+ */
+ public <T> T executeInTransaction(RedisKey key, List<RedisKey> keysToLock,
Callable<T> callable) {
+ Callable<T> txWrappedCallable = getTxWrappedCallable(callable);
+ return execute(key, keysToLock, txWrappedCallable);
+ }
+
+ private <T> Callable<T> getTxWrappedCallable(Callable<T> callable) {
+ Callable<T> txWrappedCallable = () -> {
+ T result;
+ try {
+ txManager.begin();
+ result = callable.call();
+ txManager.commit();
+ } finally {
Review comment:
I used this as a guide for the current code:
https://gemfire.docs.pivotal.io/910/geode/developing/transactions/directed_example.html.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]