Added unwatch command
This commit is contained in:
@@ -11,7 +11,7 @@ Jedis is a WORK IN PROGRESS.
|
|||||||
- Publish/Subscribe
|
- Publish/Subscribe
|
||||||
- Persistence control commands
|
- Persistence control commands
|
||||||
- Remote server control commands
|
- Remote server control commands
|
||||||
- The WATCH, UNWATCH, AUTH, SORT, BLPOP, BRPOP, ZRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE commands
|
- The AUTH, SORT, BLPOP, BRPOP, ZRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE commands
|
||||||
|
|
||||||
But stay close because things are going fast and all this will be implemented soon!
|
But stay close because things are going fast and all this will be implemented soon!
|
||||||
|
|
||||||
|
|||||||
@@ -379,4 +379,8 @@ public class Client extends Connection {
|
|||||||
public void watch(String key) throws JedisException {
|
public void watch(String key) throws JedisException {
|
||||||
sendCommand("WATCH", key);
|
sendCommand("WATCH", key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unwatch() throws JedisException {
|
||||||
|
sendCommand("UNWATCH");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -491,4 +491,9 @@ public class Jedis {
|
|||||||
return client.getStatusCodeReply();
|
return client.getStatusCodeReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String unwatch() throws JedisException {
|
||||||
|
client.unwatch();
|
||||||
|
return client.getStatusCodeReply();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,26 @@ public class TransactionCommandsTest extends Assert {
|
|||||||
List<Object> resp = t.exec();
|
List<Object> resp = t.exec();
|
||||||
assertEquals(new ArrayList<Object>(), resp);
|
assertEquals(new ArrayList<Object>(), resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void unwatch() throws JedisException, UnknownHostException,
|
||||||
|
IOException {
|
||||||
|
jedis.watch("mykey");
|
||||||
|
String val = jedis.get("mykey");
|
||||||
|
val = "foo";
|
||||||
|
String status = jedis.unwatch();
|
||||||
|
assertEquals("OK", status);
|
||||||
|
Transaction t = jedis.multi();
|
||||||
|
|
||||||
|
Jedis nj = new Jedis("localhost");
|
||||||
|
nj.connect();
|
||||||
|
nj.set("mykey", "bar");
|
||||||
|
nj.disconnect();
|
||||||
|
|
||||||
|
t.set("mykey", val);
|
||||||
|
List<Object> resp = t.exec();
|
||||||
|
List<Object> expected = new ArrayList<Object>();
|
||||||
|
expected.add("OK");
|
||||||
|
assertEquals(expected, resp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user