add WAIT command
This commit is contained in:
@@ -39,4 +39,6 @@ public interface BasicCommands {
|
|||||||
String debug(DebugParams params);
|
String debug(DebugParams params);
|
||||||
|
|
||||||
String configResetStat();
|
String configResetStat();
|
||||||
|
|
||||||
|
Long waitReplicas(int replicas, long timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1131,4 +1131,8 @@ public class BinaryClient extends Connection {
|
|||||||
args.addAll(params.getParams());
|
args.addAll(params.getParams());
|
||||||
sendCommand(ZSCAN, args.toArray(new byte[args.size()][]));
|
sendCommand(ZSCAN, args.toArray(new byte[args.size()][]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void waitReplicas(int replicas, long timeout) {
|
||||||
|
sendCommand(WAIT, toByteArray(replicas), toByteArray(timeout));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3366,4 +3366,17 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
|
|||||||
return (relpy != null ? new Double(relpy) : null);
|
return (relpy != null ? new Double(relpy) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Syncrhonous replication of Redis as described here:
|
||||||
|
* http://antirez.com/news/66
|
||||||
|
*
|
||||||
|
* Since Java Object class has implemented "wait" method, we cannot use it,
|
||||||
|
* so I had to change the name of the method. Sorry :S
|
||||||
|
*/
|
||||||
|
public Long waitReplicas(int replicas, long timeout) {
|
||||||
|
checkIsInMulti();
|
||||||
|
client.waitReplicas(replicas, timeout);
|
||||||
|
return client.getIntegerReply();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package redis.clients.jedis;
|
package redis.clients.jedis;
|
||||||
|
|
||||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||||
|
|
||||||
public interface Commands {
|
public interface Commands {
|
||||||
|
|
||||||
public void set(final String key, final String value);
|
public void set(final String key, final String value);
|
||||||
|
|
||||||
public void set(final String key, final String value, final String nxxx, final String expx, final long time);
|
public void set(final String key, final String value, final String nxxx,
|
||||||
|
final String expx, final long time);
|
||||||
|
|
||||||
public void get(final String key);
|
public void get(final String key);
|
||||||
|
|
||||||
@@ -303,4 +304,6 @@ public interface Commands {
|
|||||||
public void sscan(final String key, int cursor, final ScanParams params);
|
public void sscan(final String key, int cursor, final ScanParams params);
|
||||||
|
|
||||||
public void zscan(final String key, int cursor, final ScanParams params);
|
public void zscan(final String key, int cursor, final ScanParams params);
|
||||||
|
|
||||||
|
public void waitReplicas(int replicas, long timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
|||||||
import redis.clients.util.SafeEncoder;
|
import redis.clients.util.SafeEncoder;
|
||||||
import redis.clients.util.Slowlog;
|
import redis.clients.util.Slowlog;
|
||||||
|
|
||||||
public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands {
|
public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands, BasicCommands {
|
||||||
public Jedis(final String host) {
|
public Jedis(final String host) {
|
||||||
super(host);
|
super(host);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public final class Protocol {
|
|||||||
|
|
||||||
public static enum Command {
|
public static enum Command {
|
||||||
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL,
|
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL,
|
||||||
DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN;
|
DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, SCAN, HSCAN, SSCAN, ZSCAN, WAIT;
|
||||||
|
|
||||||
public final byte[] raw;
|
public final byte[] raw;
|
||||||
|
|
||||||
|
|||||||
@@ -112,4 +112,10 @@ public class ControlCommandsTest extends JedisCommandTestBase {
|
|||||||
resp = jedis.debug(DebugParams.RELOAD());
|
resp = jedis.debug(DebugParams.RELOAD());
|
||||||
assertNotNull(resp);
|
assertNotNull(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void waitReplicas() {
|
||||||
|
Long replicas = jedis.waitReplicas(1, 100);
|
||||||
|
assertEquals(1, replicas.longValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user