Small refactoring to make command definitions even smaller
This commit is contained in:
@@ -1,49 +1,21 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Jedis extends Client {
|
||||
public Jedis(String host) {
|
||||
super(host);
|
||||
}
|
||||
|
||||
public String ping() {
|
||||
// TODO: I want to be able to do the followin
|
||||
// return protocol.runCommand(os,
|
||||
// "PING").getSingleLineReply(inputStream);
|
||||
// or even maybe
|
||||
// return protocol.runCommand("PING").getSingleLineReply();
|
||||
|
||||
String command = protocol.buildCommand("PING");
|
||||
try {
|
||||
outputStream.write(command.getBytes());
|
||||
return protocol.getSingleLineReply(inputStream);
|
||||
} catch (IOException e) {
|
||||
// TODO Not sure what to do here
|
||||
return null;
|
||||
}
|
||||
return sendCommand("PING").getSingleLineReply();
|
||||
}
|
||||
|
||||
public String set(String key, String value) {
|
||||
String command = protocol.buildCommand("SET", key, value);
|
||||
try {
|
||||
outputStream.write(command.getBytes());
|
||||
return protocol.getSingleLineReply(inputStream);
|
||||
} catch (IOException e) {
|
||||
// TODO Not sure what to do here
|
||||
return null;
|
||||
}
|
||||
return sendCommand("SET", key, value).getSingleLineReply();
|
||||
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
String command = protocol.buildCommand("GET", key);
|
||||
try {
|
||||
outputStream.write(command.getBytes());
|
||||
return protocol.getBulkReply(inputStream);
|
||||
} catch (IOException e) {
|
||||
// TODO Not sure what to do here
|
||||
return null;
|
||||
}
|
||||
return sendCommand("GET", key).getBulkReply();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user