-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issues: In test, last GET operation is not populating reply. But if we add a PING, not only we get the reply of GET but also PING.
- Loading branch information
Showing
10 changed files
with
292 additions
and
99 deletions.
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
src/main/java/redis/clients/jedis/asyncio/CommandArguments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package redis.clients.jedis.asyncio; | ||
|
||
import redis.clients.jedis.*; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
import redis.clients.jedis.args.Rawable; | ||
import redis.clients.jedis.args.RawableFactory; | ||
import redis.clients.jedis.commands.ProtocolCommand; | ||
import redis.clients.jedis.params.IParams; | ||
import redis.clients.jedis.search.RediSearchUtil; | ||
|
||
public class CommandArguments implements Iterable<Rawable> { | ||
|
||
private final ArrayList<Rawable> args; | ||
|
||
// private boolean blocking; | ||
|
||
private CommandArguments() { | ||
throw new InstantiationError(); | ||
} | ||
|
||
public CommandArguments(ProtocolCommand command) { | ||
args = new ArrayList<>(); | ||
args.add(command); | ||
} | ||
|
||
public ProtocolCommand getCommand() { | ||
return (ProtocolCommand) args.get(0); | ||
} | ||
|
||
public CommandArguments add(Object arg) { | ||
if (arg == null) { | ||
throw new IllegalArgumentException("null is not a valid argument."); | ||
} else if (arg instanceof Rawable) { | ||
args.add((Rawable) arg); | ||
} else if (arg instanceof byte[]) { | ||
args.add(RawableFactory.from((byte[]) arg)); | ||
} else if (arg instanceof Integer) { | ||
args.add(RawableFactory.from((Integer) arg)); | ||
} else if (arg instanceof Double) { | ||
args.add(RawableFactory.from((Double) arg)); | ||
} else if (arg instanceof Boolean) { | ||
args.add(RawableFactory.from((Boolean) arg ? 1 : 0)); | ||
} else if (arg instanceof float[]) { | ||
args.add(RawableFactory.from(RediSearchUtil.toByteArray((float[]) arg))); | ||
} else if (arg instanceof String) { | ||
args.add(RawableFactory.from((String) arg)); | ||
} else if (arg instanceof GeoCoordinate) { | ||
GeoCoordinate geo = (GeoCoordinate) arg; | ||
args.add(RawableFactory.from(geo.getLongitude() + "," + geo.getLatitude())); | ||
} else { | ||
args.add(RawableFactory.from(String.valueOf(arg))); | ||
} | ||
return this; | ||
} | ||
|
||
public CommandArguments addObjects(Object... args) { | ||
for (Object arg : args) { | ||
add(arg); | ||
} | ||
return this; | ||
} | ||
|
||
public CommandArguments addObjects(Collection args) { | ||
args.forEach(arg -> add(arg)); | ||
return this; | ||
} | ||
|
||
public CommandArguments key(Object key) { | ||
if (key instanceof Rawable) { | ||
Rawable raw = (Rawable) key; | ||
// processKey(raw.getRaw()); | ||
args.add(raw); | ||
} else if (key instanceof byte[]) { | ||
byte[] raw = (byte[]) key; | ||
// processKey(raw); | ||
args.add(RawableFactory.from(raw)); | ||
} else if (key instanceof String) { | ||
String raw = (String) key; | ||
// processKey(raw); | ||
args.add(RawableFactory.from(raw)); | ||
} else { | ||
throw new IllegalArgumentException("\"" + key.toString() + "\" is not a valid argument."); | ||
} | ||
return this; | ||
} | ||
|
||
public final CommandArguments keys(Object... keys) { | ||
for (Object key : keys) { | ||
key(key); | ||
} | ||
return this; | ||
} | ||
|
||
public final CommandArguments keys(Collection keys) { | ||
keys.forEach(key -> key(key)); | ||
return this; | ||
} | ||
|
||
// public final CommandArguments addParams(IParams params) { | ||
// params.addParams(this); | ||
// return this; | ||
// } | ||
// | ||
// protected CommandArguments processKey(byte[] key) { | ||
// // do nothing | ||
// return this; | ||
// } | ||
// | ||
// protected final CommandArguments processKeys(byte[]... keys) { | ||
// for (byte[] key : keys) { | ||
// processKey(key); | ||
// } | ||
// return this; | ||
// } | ||
// | ||
// protected CommandArguments processKey(String key) { | ||
// // do nothing | ||
// return this; | ||
// } | ||
// | ||
// protected final CommandArguments processKeys(String... keys) { | ||
// for (String key : keys) { | ||
// processKey(key); | ||
// } | ||
// return this; | ||
// } | ||
|
||
public int size() { | ||
return args.size(); | ||
} | ||
|
||
@Override | ||
public Iterator<Rawable> iterator() { | ||
return args.iterator(); | ||
} | ||
// | ||
// public boolean isBlocking() { | ||
// return blocking; | ||
// } | ||
// | ||
// public CommandArguments blocking() { | ||
// this.blocking = true; | ||
// return this; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/redis/clients/jedis/asyncio/CommandObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package redis.clients.jedis.asyncio; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import redis.clients.jedis.asyncio.replies.CommandReply; | ||
|
||
public class CommandObject<T> extends CompletableFuture<T> { | ||
|
||
private final CommandArguments arguments; | ||
private final CommandReply<T> reply; | ||
|
||
public CommandObject(CommandArguments arguments, CommandReply<T> reply) { | ||
this.arguments = arguments; | ||
this.reply = reply; | ||
} | ||
|
||
public CommandArguments getArguments() { | ||
return arguments; | ||
} | ||
|
||
public CommandReply<T> getReply() { | ||
return reply; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
src/main/java/redis/clients/jedis/asyncio/RedisClientHandler.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
src/main/java/redis/clients/jedis/asyncio/replies/CommandReply.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package redis.clients.jedis.asyncio.replies; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
public class CommandReply<T> { | ||
|
||
private T reply = null; | ||
|
||
public CommandReply() { | ||
} | ||
|
||
public T get() { | ||
return reply; | ||
} | ||
|
||
public void setReply(T reply) { | ||
this.reply = reply; | ||
} | ||
|
||
public void parse(ByteBuffer bytes) { | ||
// override | ||
} | ||
} |
Oops, something went wrong.