-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support INFO command in UnifiedJedis #4078
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package redis.clients.jedis.util; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* The collection of replies where a command is broadcasted to multiple nodes, but the replies are expected to differ | ||
* even in ideal situation. | ||
*/ | ||
public class JedisBroadcastReplies { | ||
|
||
private static final Object DUMMY_OBJECT = new Object(); | ||
|
||
private final Map<Object, Object> replies; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we don't a specified solution for this, e.g. in ConnectionProvider and CommandExecutor interfaces, yet. For example, in ConnectionProvider interface the respective method definition is |
||
|
||
public JedisBroadcastReplies() { | ||
this(new HashMap<>()); | ||
} | ||
|
||
public JedisBroadcastReplies(int size) { | ||
this(new HashMap<>(size)); | ||
} | ||
|
||
private JedisBroadcastReplies(Map<Object, Object> replies) { | ||
this.replies = replies; | ||
} | ||
|
||
public void addReply(Object node, Object reply) { | ||
replies.put(node, reply); | ||
} | ||
|
||
public Map<Object, Object> getReplies() { | ||
return Collections.unmodifiableMap(replies); | ||
} | ||
|
||
public static JedisBroadcastReplies singleton(Object reply) { | ||
return new JedisBroadcastReplies(Collections.singletonMap(DUMMY_OBJECT, reply)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be a bit strange API when connecting to standalone Redis using let's say UnifiedJedis.
Then you will get a
JedisBroadcastReplies
which makes sense for the cluster.But in case of standalone, you will get
JedisBroadcastReplies
, and to get to actual value need to invokeJedisBroadcastReplies::getReplies(with host/port)
or end up with something like
infoReplies.getReplies().values().stream().findFirst().get()
just to get the value