update transaction api with all the new commands

This commit is contained in:
Jonathan Leibiusky
2011-01-20 12:18:25 -03:00
parent 1857dd3413
commit 66fc6be729
7 changed files with 72 additions and 4 deletions

View File

@@ -2896,9 +2896,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param timeout * @param timeout
* @return the element * @return the element
*/ */
public String brpoplpush(byte[] source, byte[] destination, int timeout) { public byte[] brpoplpush(byte[] source, byte[] destination, int timeout) {
client.brpoplpush(source, destination, timeout); client.brpoplpush(source, destination, timeout);
return client.getBulkReply(); return client.getBinaryBulkReply();
} }
/** /**

View File

@@ -3,6 +3,8 @@ package redis.clients.jedis;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
public class BinaryTransaction { public class BinaryTransaction {
protected Client client = null; protected Client client = null;
protected boolean inTransaction = true; protected boolean inTransaction = true;
@@ -430,4 +432,20 @@ public class BinaryTransaction {
inTransaction = false; inTransaction = false;
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String setbit(byte[] key, int offset, byte[] value) {
client.setbit(key, offset, value);
return client.getStatusCodeReply();
}
public String getbit(byte[] key, int offset) {
client.getbit(key, offset);
return client.getStatusCodeReply();
}
public String linsert(final byte[] key, final LIST_POSITION where,
final byte[] pivot, final byte[] value) {
client.linsert(key, where, pivot, value);
return client.getStatusCodeReply();
}
} }

View File

@@ -230,4 +230,10 @@ public interface Commands {
public void configGet(final String pattern); public void configGet(final String pattern);
public void configResetStat(); public void configResetStat();
public void multi();
public void exec();
public void discard();
} }

View File

@@ -438,4 +438,16 @@ public class Pipeline implements Commands {
public void lastsave() { public void lastsave() {
client.lastsave(); client.lastsave();
} }
public void discard() {
client.discard();
}
public void exec() {
client.exec();
}
public void multi() {
client.multi();
}
} }

View File

@@ -434,5 +434,17 @@ public abstract class PipelineBlock implements Commands {
client.lastsave(); client.lastsave();
} }
public void discard() {
client.discard();
}
public void exec() {
client.exec();
}
public void multi() {
client.multi();
}
public abstract void execute(); public abstract void execute();
} }

View File

@@ -2,6 +2,8 @@ package redis.clients.jedis;
import java.util.Map; import java.util.Map;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
public class Transaction extends BinaryTransaction { public class Transaction extends BinaryTransaction {
public Transaction() { public Transaction() {
} }
@@ -389,4 +391,20 @@ public class Transaction extends BinaryTransaction {
client.sort(key, sortingParameters); client.sort(key, sortingParameters);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String setbit(String key, long offset, String value) {
client.setbit(key, offset, value);
return client.getStatusCodeReply();
}
public String getbit(String key, long offset) {
client.getbit(key, offset);
return client.getStatusCodeReply();
}
public String linsert(final String key, final LIST_POSITION where,
final String pivot, final String value) {
client.linsert(key, where, pivot, value);
return client.getStatusCodeReply();
}
} }

View File

@@ -3,6 +3,7 @@ package redis.clients.jedis.tests.commands;
import java.io.IOException; import java.io.IOException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
@@ -621,9 +622,10 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
})).start(); })).start();
element = jedis.brpoplpush("foo".getBytes(), "bar".getBytes(), 0); byte[] brpoplpush = jedis.brpoplpush("foo".getBytes(),
"bar".getBytes(), 0);
assertEquals("a", element); assertTrue(Arrays.equals("a".getBytes(), brpoplpush));
assertEquals(1, jedis.llen("bar").longValue()); assertEquals(1, jedis.llen("bar").longValue());
assertEquals("a", jedis.lrange("bar", 0, -1).get(0)); assertEquals("a", jedis.lrange("bar", 0, -1).get(0));