denis-chudov commented on code in PR #3725:
URL: https://github.com/apache/ignite-3/pull/3725#discussion_r1599949165


##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageWriteHandler.java:
##########
@@ -278,4 +309,50 @@ boolean beforeApply(Command command) {
 
         return false;
     }
+
+    private static class IdempotentCommandCache {
+        @Nullable
+        final Serializable result;
+
+        final HybridTimestamp commandStartTime;
+
+        IdempotentCommandCache(@Nullable Serializable result, HybridTimestamp 
commandStartTime) {
+            this.result = result;
+            this.commandStartTime = commandStartTime;
+        }
+    }
+
+    private class ResultCachingClosure implements CommandClosure<WriteCommand> 
{
+        CommandClosure<WriteCommand> closure;
+
+        ResultCachingClosure(CommandClosure<WriteCommand> closure) {
+            this.closure = closure;
+
+            assert closure.command() instanceof IdempotentCommand;
+        }
+
+        @Override
+        public long index() {
+            return closure.index();
+        }
+
+        @Override
+        public long term() {
+            return closure.term();
+        }
+
+        @Override
+        public WriteCommand command() {
+            return closure.command();
+        }
+
+        @Override
+        public void result(@Nullable Serializable res) {
+            IdempotentCommand command = (IdempotentCommand) closure.command();
+
+            idempotentCommandCache.put(command.id(), new 
IdempotentCommandCache(res, command.initiatorTime()));

Review Comment:
   `initiatorTime` is almost the same, but from initiator node. Makes no sense 
to call System.currentTimeMillies once more.



-- 
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]

Reply via email to