-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Jedis test plan coverage for CSC #3918
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
Changes from all commits
34a63d3
75715b6
6fd9dc7
36f1966
be54188
7c88aac
82cacd5
0527b2c
a7d4a81
cd7fdb2
41b07ad
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 |
|---|---|---|
|
|
@@ -3,8 +3,11 @@ | |
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
|
|
||
| import redis.clients.jedis.annots.Internal; | ||
| import redis.clients.jedis.args.Rawable; | ||
| import redis.clients.jedis.args.RawableFactory; | ||
| import redis.clients.jedis.commands.ProtocolCommand; | ||
|
|
@@ -14,14 +17,20 @@ | |
| public class CommandArguments implements Iterable<Rawable> { | ||
|
|
||
| private final ArrayList<Rawable> args; | ||
| private final ArrayList<Object> keys; | ||
|
|
||
| private List<Object> keys; | ||
|
|
||
| private boolean blocking; | ||
|
|
||
| private CommandArguments() { | ||
| throw new InstantiationError(); | ||
| } | ||
|
|
||
| public CommandArguments(ProtocolCommand command) { | ||
| args = new ArrayList<>(); | ||
| args.add(command); | ||
| keys = new ArrayList<>(); | ||
|
|
||
| keys = Collections.emptyList(); | ||
| } | ||
|
|
||
| public ProtocolCommand getCommand() { | ||
|
|
@@ -113,10 +122,25 @@ public CommandArguments key(Object key) { | |
| } else { | ||
| throw new IllegalArgumentException("\"" + key.toString() + "\" is not a valid argument."); | ||
| } | ||
| keys.add(key); | ||
|
|
||
| addKeyInKeys(key); | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
| private void addKeyInKeys(Object key) { | ||
|
Contributor
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. what are the sample cases we get the benefit from a collections.list??
Contributor
Author
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. most Redis commands have single key. this way we are avoiding creation of an array just for an entry. so saving memory. |
||
| if (keys.isEmpty()) { | ||
| keys = Collections.singletonList(key); | ||
| } else if (keys.size() == 1) { | ||
| List oldKeys = keys; | ||
| keys = new ArrayList(); | ||
| keys.addAll(oldKeys); | ||
| keys.add(key); | ||
| } else { | ||
| keys.add(key); | ||
| } | ||
| } | ||
|
|
||
| public final CommandArguments keys(Object... keys) { | ||
| Arrays.stream(keys).forEach(this::key); | ||
| return this; | ||
|
|
@@ -133,6 +157,7 @@ public final CommandArguments addParams(IParams params) { | |
| } | ||
|
|
||
| protected CommandArguments processKey(byte[] key) { | ||
| // do nothing | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -144,6 +169,7 @@ protected final CommandArguments processKeys(byte[]... keys) { | |
| } | ||
|
|
||
| protected CommandArguments processKey(String key) { | ||
| // do nothing | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -163,8 +189,9 @@ public Iterator<Rawable> iterator() { | |
| return args.iterator(); | ||
| } | ||
|
|
||
| public Object[] getKeys() { | ||
| return keys.toArray(); | ||
| @Internal | ||
| public List<Object> getKeys() { | ||
| return keys; | ||
| } | ||
|
|
||
| public boolean isBlocking() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package redis.clients.jedis.csc; | ||
|
|
||
| import java.util.List; | ||
| import redis.clients.jedis.commands.ProtocolCommand; | ||
|
|
||
| public interface Cacheable { | ||
|
|
||
| boolean isCacheable(ProtocolCommand command, List<Object> keys); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.