Merge branch 'flush' of git://github.com/pietern/jedis into pietern-flush

This commit is contained in:
Jonathan Leibiusky
2011-02-28 10:37:43 -03:00
3 changed files with 18 additions and 3 deletions

View File

@@ -53,6 +53,14 @@ public class Connection {
this.host = host;
}
protected void flush() {
try {
outputStream.flush();
} catch (IOException e) {
throw new JedisConnectionException(e);
}
}
protected Connection sendCommand(final Command cmd, final String... args) {
final byte[][] bargs = new byte[args.length][];
for (int i = 0; i < args.length; i++) {
@@ -135,6 +143,7 @@ public class Connection {
}
protected String getStatusCodeReply() {
flush();
pipelinedCommands--;
final byte[] resp = (byte[]) protocol.read(inputStream);
if (null == resp) {
@@ -154,11 +163,13 @@ public class Connection {
}
public byte[] getBinaryBulkReply() {
flush();
pipelinedCommands--;
return (byte[]) protocol.read(inputStream);
}
public Long getIntegerReply() {
flush();
pipelinedCommands--;
return (Long) protocol.read(inputStream);
}
@@ -181,18 +192,21 @@ public class Connection {
@SuppressWarnings("unchecked")
public List<byte[]> getBinaryMultiBulkReply() {
flush();
pipelinedCommands--;
return (List<byte[]>) protocol.read(inputStream);
}
@SuppressWarnings("unchecked")
public List<Object> getObjectMultiBulkReply() {
flush();
pipelinedCommands--;
return (List<Object>) protocol.read(inputStream);
}
public List<Object> getAll() {
List<Object> all = new ArrayList<Object>();
flush();
while (pipelinedCommands > 0) {
all.add(protocol.read(inputStream));
pipelinedCommands--;
@@ -201,6 +215,7 @@ public class Connection {
}
public Object getOne() {
flush();
pipelinedCommands--;
return protocol.read(inputStream);
}

View File

@@ -44,7 +44,6 @@ public final class Protocol {
os.write(arg);
os.writeCrLf();
}
os.flush();
} catch (IOException e) {
throw new JedisConnectionException(e);
}