add publish command to Pipeline

This commit is contained in:
Jonathan Leibiusky
2011-05-11 22:29:42 -03:00
parent 86fdf63cc9
commit cd3b50268e
2 changed files with 21 additions and 0 deletions

View File

@@ -1155,4 +1155,14 @@ public class Pipeline extends Queable {
public void multi() {
client.multi();
}
public Response<Long> publish(String channel, String message) {
client.publish(channel, message);
return getResponse(BuilderFactory.LONG);
}
public Response<Long> publish(byte[] channel, byte[] message) {
client.publish(channel, message);
return getResponse(BuilderFactory.LONG);
}
}

View File

@@ -103,4 +103,15 @@ public class PipeliningTest extends Assert {
string.get();
p.sync();
}
@Test
public void pipelineWithPubSub() {
Pipeline pipelined = jedis.pipelined();
Response<Long> p1 = pipelined.publish("foo", "bar");
Response<Long> p2 = pipelined.publish("foo".getBytes(), "bar"
.getBytes());
pipelined.sync();
assertEquals(0, p1.get().longValue());
assertEquals(0, p2.get().longValue());
}
}