New exception management. Less exceptions... assume everything works
This commit is contained in:
@@ -14,147 +14,143 @@ public class Client extends Connection {
|
||||
super(host, port);
|
||||
}
|
||||
|
||||
public void ping() throws JedisException {
|
||||
public void ping() {
|
||||
sendCommand("PING");
|
||||
}
|
||||
|
||||
public void set(String key, String value) throws JedisException {
|
||||
public void set(String key, String value) {
|
||||
sendCommand("SET", key, value);
|
||||
}
|
||||
|
||||
public void get(String key) throws JedisException {
|
||||
public void get(String key) {
|
||||
sendCommand("GET", key);
|
||||
}
|
||||
|
||||
public void quit() throws JedisException {
|
||||
public void quit() {
|
||||
sendCommand("QUIT");
|
||||
}
|
||||
|
||||
public void exists(String key) throws JedisException {
|
||||
public void exists(String key) {
|
||||
sendCommand("EXISTS", key);
|
||||
}
|
||||
|
||||
public void del(String... keys) throws JedisException {
|
||||
public void del(String... keys) {
|
||||
sendCommand("DEL", keys);
|
||||
}
|
||||
|
||||
public void type(String key) throws JedisException {
|
||||
public void type(String key) {
|
||||
sendCommand("TYPE", key);
|
||||
}
|
||||
|
||||
public void flushDB() throws JedisException {
|
||||
public void flushDB() {
|
||||
sendCommand("FLUSHDB");
|
||||
}
|
||||
|
||||
public void keys(String pattern) throws JedisException {
|
||||
public void keys(String pattern) {
|
||||
sendCommand("KEYS", pattern);
|
||||
}
|
||||
|
||||
public void randomKey() throws JedisException {
|
||||
public void randomKey() {
|
||||
sendCommand("RANDOMKEY");
|
||||
}
|
||||
|
||||
public void rename(String oldkey, String newkey) throws JedisException {
|
||||
public void rename(String oldkey, String newkey) {
|
||||
sendCommand("RENAME", oldkey, newkey);
|
||||
}
|
||||
|
||||
public void renamenx(String oldkey, String newkey) throws JedisException {
|
||||
public void renamenx(String oldkey, String newkey) {
|
||||
sendCommand("RENAMENX", oldkey, newkey);
|
||||
}
|
||||
|
||||
public void dbSize() throws JedisException {
|
||||
public void dbSize() {
|
||||
sendCommand("DBSIZE");
|
||||
}
|
||||
|
||||
public void expire(String key, int seconds) throws JedisException {
|
||||
public void expire(String key, int seconds) {
|
||||
sendCommand("EXPIRE", key, String.valueOf(seconds));
|
||||
}
|
||||
|
||||
public void expireAt(String key, long unixTime) throws JedisException {
|
||||
public void expireAt(String key, long unixTime) {
|
||||
sendCommand("EXPIREAT", key, String.valueOf(unixTime));
|
||||
}
|
||||
|
||||
public void ttl(String key) throws JedisException {
|
||||
public void ttl(String key) {
|
||||
sendCommand("TTL", key);
|
||||
}
|
||||
|
||||
public void select(int index) throws JedisException {
|
||||
public void select(int index) {
|
||||
sendCommand("SELECT", String.valueOf(index));
|
||||
}
|
||||
|
||||
public void move(String key, int dbIndex) throws JedisException {
|
||||
public void move(String key, int dbIndex) {
|
||||
sendCommand("MOVE", key, String.valueOf(dbIndex));
|
||||
}
|
||||
|
||||
public void flushAll() throws JedisException {
|
||||
public void flushAll() {
|
||||
sendCommand("FLUSHALL");
|
||||
}
|
||||
|
||||
public void getSet(String key, String value) throws JedisException {
|
||||
public void getSet(String key, String value) {
|
||||
sendCommand("GETSET", key, value);
|
||||
}
|
||||
|
||||
public void mget(String... keys) throws JedisException {
|
||||
public void mget(String... keys) {
|
||||
sendCommand("MGET", keys);
|
||||
}
|
||||
|
||||
public void setnx(String key, String value) throws JedisException {
|
||||
public void setnx(String key, String value) {
|
||||
sendCommand("SETNX", key, value);
|
||||
}
|
||||
|
||||
public void setex(String key, int seconds, String value)
|
||||
throws JedisException {
|
||||
public void setex(String key, int seconds, String value) {
|
||||
sendCommand("SETEX", key, String.valueOf(seconds), value);
|
||||
}
|
||||
|
||||
public void mset(String... keysvalues) throws JedisException {
|
||||
public void mset(String... keysvalues) {
|
||||
sendCommand("MSET", keysvalues);
|
||||
}
|
||||
|
||||
public void msetnx(String... keysvalues) throws JedisException {
|
||||
public void msetnx(String... keysvalues) {
|
||||
sendCommand("MSETNX", keysvalues);
|
||||
}
|
||||
|
||||
public void decrBy(String key, int integer) throws JedisException {
|
||||
public void decrBy(String key, int integer) {
|
||||
sendCommand("DECRBY", key, String.valueOf(integer));
|
||||
}
|
||||
|
||||
public void decr(String key) throws JedisException {
|
||||
public void decr(String key) {
|
||||
sendCommand("DECR", key);
|
||||
}
|
||||
|
||||
public void incrBy(String key, int integer) throws JedisException {
|
||||
public void incrBy(String key, int integer) {
|
||||
sendCommand("INCRBY", key, String.valueOf(integer));
|
||||
}
|
||||
|
||||
public void incr(String key) throws JedisException {
|
||||
public void incr(String key) {
|
||||
sendCommand("INCR", key);
|
||||
}
|
||||
|
||||
public void append(String key, String value) throws JedisException {
|
||||
public void append(String key, String value) {
|
||||
sendCommand("APPEND", key, value);
|
||||
}
|
||||
|
||||
public void substr(String key, int start, int end) throws JedisException {
|
||||
public void substr(String key, int start, int end) {
|
||||
sendCommand("SUBSTR", key, String.valueOf(start), String.valueOf(end));
|
||||
}
|
||||
|
||||
public void hset(String key, String field, String value)
|
||||
throws JedisException {
|
||||
public void hset(String key, String field, String value) {
|
||||
sendCommand("HSET", key, field, value);
|
||||
}
|
||||
|
||||
public void hget(String key, String field) throws JedisException {
|
||||
public void hget(String key, String field) {
|
||||
sendCommand("HGET", key, field);
|
||||
}
|
||||
|
||||
public void hsetnx(String key, String field, String value)
|
||||
throws JedisException {
|
||||
public void hsetnx(String key, String field, String value) {
|
||||
sendCommand("HSETNX", key, field, value);
|
||||
}
|
||||
|
||||
public void hmset(String key, Map<String, String> hash)
|
||||
throws JedisException {
|
||||
public void hmset(String key, Map<String, String> hash) {
|
||||
List<String> params = new ArrayList<String>();
|
||||
params.add(key);
|
||||
|
||||
@@ -165,243 +161,233 @@ public class Client extends Connection {
|
||||
sendCommand("HMSET", params.toArray(new String[params.size()]));
|
||||
}
|
||||
|
||||
public void hmget(String key, String... fields) throws JedisException {
|
||||
public void hmget(String key, String... fields) {
|
||||
String[] params = new String[fields.length + 1];
|
||||
params[0] = key;
|
||||
System.arraycopy(fields, 0, params, 1, fields.length);
|
||||
sendCommand("HMGET", params);
|
||||
}
|
||||
|
||||
public void hincrBy(String key, String field, int value)
|
||||
throws JedisException {
|
||||
public void hincrBy(String key, String field, int value) {
|
||||
sendCommand("HINCRBY", key, field, String.valueOf(value));
|
||||
}
|
||||
|
||||
public void hexists(String key, String field) throws JedisException {
|
||||
public void hexists(String key, String field) {
|
||||
sendCommand("HEXISTS", key, field);
|
||||
}
|
||||
|
||||
public void hdel(String key, String field) throws JedisException {
|
||||
public void hdel(String key, String field) {
|
||||
sendCommand("HDEL", key, field);
|
||||
}
|
||||
|
||||
public void hlen(String key) throws JedisException {
|
||||
public void hlen(String key) {
|
||||
sendCommand("HLEN", key);
|
||||
}
|
||||
|
||||
public void hkeys(String key) throws JedisException {
|
||||
public void hkeys(String key) {
|
||||
sendCommand("HKEYS", key);
|
||||
}
|
||||
|
||||
public void hvals(String key) throws JedisException {
|
||||
public void hvals(String key) {
|
||||
sendCommand("HVALS", key);
|
||||
}
|
||||
|
||||
public void hgetAll(String key) throws JedisException {
|
||||
public void hgetAll(String key) {
|
||||
sendCommand("HGETALL", key);
|
||||
}
|
||||
|
||||
public void rpush(String key, String string) throws JedisException {
|
||||
public void rpush(String key, String string) {
|
||||
sendCommand("RPUSH", key, string);
|
||||
}
|
||||
|
||||
public void lpush(String key, String string) throws JedisException {
|
||||
public void lpush(String key, String string) {
|
||||
sendCommand("LPUSH", key, string);
|
||||
}
|
||||
|
||||
public void llen(String key) throws JedisException {
|
||||
public void llen(String key) {
|
||||
sendCommand("LLEN", key);
|
||||
}
|
||||
|
||||
public void lrange(String key, int start, int end) throws JedisException {
|
||||
public void lrange(String key, int start, int end) {
|
||||
sendCommand("LRANGE", key, String.valueOf(start), String.valueOf(end));
|
||||
}
|
||||
|
||||
public void ltrim(String key, int start, int end) throws JedisException {
|
||||
public void ltrim(String key, int start, int end) {
|
||||
sendCommand("LTRIM", key, String.valueOf(start), String.valueOf(end));
|
||||
}
|
||||
|
||||
public void lindex(String key, int index) throws JedisException {
|
||||
public void lindex(String key, int index) {
|
||||
sendCommand("LINDEX", key, String.valueOf(index));
|
||||
}
|
||||
|
||||
public void lset(String key, int index, String value) throws JedisException {
|
||||
public void lset(String key, int index, String value) {
|
||||
sendCommand("LSET", key, String.valueOf(index), value);
|
||||
}
|
||||
|
||||
public void lrem(String key, int count, String value) throws JedisException {
|
||||
public void lrem(String key, int count, String value) {
|
||||
sendCommand("LREM", key, String.valueOf(count), value);
|
||||
}
|
||||
|
||||
public void lpop(String key) throws JedisException {
|
||||
public void lpop(String key) {
|
||||
sendCommand("LPOP", key);
|
||||
}
|
||||
|
||||
public void rpop(String key) throws JedisException {
|
||||
public void rpop(String key) {
|
||||
sendCommand("RPOP", key);
|
||||
}
|
||||
|
||||
public void rpoplpush(String srckey, String dstkey) throws JedisException {
|
||||
public void rpoplpush(String srckey, String dstkey) {
|
||||
sendCommand("RPOPLPUSH", srckey, dstkey);
|
||||
}
|
||||
|
||||
public void sadd(String key, String member) throws JedisException {
|
||||
public void sadd(String key, String member) {
|
||||
sendCommand("SADD", key, member);
|
||||
}
|
||||
|
||||
public void smembers(String key) throws JedisException {
|
||||
public void smembers(String key) {
|
||||
sendCommand("SMEMBERS", key);
|
||||
}
|
||||
|
||||
public void srem(String key, String member) throws JedisException {
|
||||
public void srem(String key, String member) {
|
||||
sendCommand("SREM", key, member);
|
||||
}
|
||||
|
||||
public void spop(String key) throws JedisException {
|
||||
public void spop(String key) {
|
||||
sendCommand("SPOP", key);
|
||||
}
|
||||
|
||||
public void smove(String srckey, String dstkey, String member)
|
||||
throws JedisException {
|
||||
public void smove(String srckey, String dstkey, String member) {
|
||||
sendCommand("SMOVE", srckey, dstkey, member);
|
||||
}
|
||||
|
||||
public void scard(String key) throws JedisException {
|
||||
public void scard(String key) {
|
||||
sendCommand("SCARD", key);
|
||||
}
|
||||
|
||||
public void sismember(String key, String member) throws JedisException {
|
||||
public void sismember(String key, String member) {
|
||||
sendCommand("SISMEMBER", key, member);
|
||||
}
|
||||
|
||||
public void sinter(String... keys) throws JedisException {
|
||||
public void sinter(String... keys) {
|
||||
sendCommand("SINTER", keys);
|
||||
}
|
||||
|
||||
public void sinterstore(String dstkey, String... keys)
|
||||
throws JedisException {
|
||||
public void sinterstore(String dstkey, String... keys) {
|
||||
String[] params = new String[keys.length + 1];
|
||||
params[0] = dstkey;
|
||||
System.arraycopy(keys, 0, params, 1, keys.length);
|
||||
sendCommand("SINTERSTORE", params);
|
||||
}
|
||||
|
||||
public void sunion(String... keys) throws JedisException {
|
||||
public void sunion(String... keys) {
|
||||
sendCommand("SUNION", keys);
|
||||
}
|
||||
|
||||
public void sunionstore(String dstkey, String... keys)
|
||||
throws JedisException {
|
||||
public void sunionstore(String dstkey, String... keys) {
|
||||
String[] params = new String[keys.length + 1];
|
||||
params[0] = dstkey;
|
||||
System.arraycopy(keys, 0, params, 1, keys.length);
|
||||
sendCommand("SUNIONSTORE", params);
|
||||
}
|
||||
|
||||
public void sdiff(String... keys) throws JedisException {
|
||||
public void sdiff(String... keys) {
|
||||
sendCommand("SDIFF", keys);
|
||||
}
|
||||
|
||||
public void sdiffstore(String dstkey, String... keys) throws JedisException {
|
||||
public void sdiffstore(String dstkey, String... keys) {
|
||||
String[] params = new String[keys.length + 1];
|
||||
params[0] = dstkey;
|
||||
System.arraycopy(keys, 0, params, 1, keys.length);
|
||||
sendCommand("SDIFFSTORE", params);
|
||||
}
|
||||
|
||||
public void srandmember(String key) throws JedisException {
|
||||
public void srandmember(String key) {
|
||||
sendCommand("SRANDMEMBER", key);
|
||||
}
|
||||
|
||||
public void zadd(String key, double score, String member)
|
||||
throws JedisException {
|
||||
public void zadd(String key, double score, String member) {
|
||||
sendCommand("ZADD", key, String.valueOf(score), member);
|
||||
}
|
||||
|
||||
public void zrange(String key, int start, int end) throws JedisException {
|
||||
public void zrange(String key, int start, int end) {
|
||||
sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end));
|
||||
}
|
||||
|
||||
public void zrem(String key, String member) throws JedisException {
|
||||
public void zrem(String key, String member) {
|
||||
sendCommand("ZREM", key, member);
|
||||
}
|
||||
|
||||
public void zincrby(String key, double score, String member)
|
||||
throws JedisException {
|
||||
public void zincrby(String key, double score, String member) {
|
||||
sendCommand("ZINCRBY", key, String.valueOf(score), member);
|
||||
}
|
||||
|
||||
public void zrank(String key, String member) throws JedisException {
|
||||
public void zrank(String key, String member) {
|
||||
sendCommand("ZRANK", key, member);
|
||||
}
|
||||
|
||||
public void zrevrank(String key, String member) throws JedisException {
|
||||
public void zrevrank(String key, String member) {
|
||||
sendCommand("ZREVRANK", key, member);
|
||||
}
|
||||
|
||||
public void zrevrange(String key, int start, int end) throws JedisException {
|
||||
public void zrevrange(String key, int start, int end) {
|
||||
sendCommand("ZREVRANGE", key, String.valueOf(start), String
|
||||
.valueOf(end));
|
||||
}
|
||||
|
||||
public void zrangeWithScores(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public void zrangeWithScores(String key, int start, int end) {
|
||||
sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end),
|
||||
"WITHSCORES");
|
||||
}
|
||||
|
||||
public void zrevrangeWithScores(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public void zrevrangeWithScores(String key, int start, int end) {
|
||||
sendCommand("ZREVRANGE", key, String.valueOf(start), String
|
||||
.valueOf(end), "WITHSCORES");
|
||||
}
|
||||
|
||||
public void zcard(String key) throws JedisException {
|
||||
public void zcard(String key) {
|
||||
sendCommand("ZCARD", key);
|
||||
}
|
||||
|
||||
public void zscore(String key, String member) throws JedisException {
|
||||
public void zscore(String key, String member) {
|
||||
sendCommand("ZSCORE", key, member);
|
||||
}
|
||||
|
||||
public void multi() throws JedisException {
|
||||
public void multi() {
|
||||
sendCommand("MULTI");
|
||||
}
|
||||
|
||||
public void discard() throws JedisException {
|
||||
public void discard() {
|
||||
sendCommand("MULTI");
|
||||
}
|
||||
|
||||
public void exec() throws JedisException {
|
||||
public void exec() {
|
||||
sendCommand("EXEC");
|
||||
}
|
||||
|
||||
public void watch(String key) throws JedisException {
|
||||
public void watch(String key) {
|
||||
sendCommand("WATCH", key);
|
||||
}
|
||||
|
||||
public void unwatch() throws JedisException {
|
||||
public void unwatch() {
|
||||
sendCommand("UNWATCH");
|
||||
}
|
||||
|
||||
public void sort(String key) throws JedisException {
|
||||
public void sort(String key) {
|
||||
sendCommand("SORT", key);
|
||||
}
|
||||
|
||||
public void sort(String key, SortingParams sortingParameters)
|
||||
throws JedisException {
|
||||
public void sort(String key, SortingParams sortingParameters) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
args.add(key);
|
||||
args.addAll(sortingParameters.getParams());
|
||||
sendCommand("SORT", args.toArray(new String[args.size()]));
|
||||
}
|
||||
|
||||
public void blpop(String[] args) throws JedisException {
|
||||
public void blpop(String[] args) {
|
||||
sendCommand("BLPOP", args);
|
||||
}
|
||||
|
||||
public void sort(String key, SortingParams sortingParameters, String dstkey)
|
||||
throws JedisException {
|
||||
public void sort(String key, SortingParams sortingParameters, String dstkey) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
args.add(key);
|
||||
args.addAll(sortingParameters.getParams());
|
||||
@@ -410,15 +396,15 @@ public class Client extends Connection {
|
||||
sendCommand("SORT", args.toArray(new String[args.size()]));
|
||||
}
|
||||
|
||||
public void sort(String key, String dstkey) throws JedisException {
|
||||
public void sort(String key, String dstkey) {
|
||||
sendCommand("SORT", key, "STORE", dstkey);
|
||||
}
|
||||
|
||||
public void brpop(String[] args) throws JedisException {
|
||||
public void brpop(String[] args) {
|
||||
sendCommand("BRPOP", args);
|
||||
}
|
||||
|
||||
public void auth(String password) throws JedisException {
|
||||
public void auth(String password) {
|
||||
sendCommand("AUTH", password);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ public class Connection {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
protected Connection sendCommand(String name, String... args)
|
||||
throws JedisException {
|
||||
protected Connection sendCommand(String name, String... args) {
|
||||
if (!isConnected()) {
|
||||
throw new JedisException("Please connect Jedis before using it.");
|
||||
}
|
||||
@@ -79,24 +78,24 @@ public class Connection {
|
||||
return connected;
|
||||
}
|
||||
|
||||
protected String getStatusCodeReply() throws JedisException {
|
||||
protected String getStatusCodeReply() {
|
||||
return protocol.getStatusCodeReply(inputStream);
|
||||
}
|
||||
|
||||
public String getBulkReply() throws JedisException {
|
||||
public String getBulkReply() {
|
||||
return protocol.getBulkReply(inputStream);
|
||||
}
|
||||
|
||||
public int getIntegerReply() throws JedisException {
|
||||
public int getIntegerReply() {
|
||||
return protocol.getIntegerReply(inputStream);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getMultiBulkReply() throws JedisException {
|
||||
public List<String> getMultiBulkReply() {
|
||||
return (List<String>) (List<?>) protocol.getMultiBulkReply(inputStream);
|
||||
}
|
||||
|
||||
public List<Object> getObjectMultiBulkReply() throws JedisException {
|
||||
public List<Object> getObjectMultiBulkReply() {
|
||||
return protocol.getMultiBulkReply(inputStream);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,222 +21,216 @@ public class Jedis {
|
||||
client = new Client(host, port);
|
||||
}
|
||||
|
||||
public String ping() throws JedisException {
|
||||
public String ping() {
|
||||
client.ping();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String set(String key, String value) throws JedisException {
|
||||
public String set(String key, String value) {
|
||||
client.set(key, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String get(String key) throws JedisException {
|
||||
public String get(String key) {
|
||||
client.sendCommand("GET", key);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public void quit() throws JedisException {
|
||||
public void quit() {
|
||||
client.quit();
|
||||
}
|
||||
|
||||
public int exists(String key) throws JedisException {
|
||||
public int exists(String key) {
|
||||
client.exists(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int del(String... keys) throws JedisException {
|
||||
public int del(String... keys) {
|
||||
client.del(keys);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String type(String key) throws JedisException {
|
||||
public String type(String key) {
|
||||
client.type(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String flushDB() throws JedisException {
|
||||
public String flushDB() {
|
||||
client.flushDB();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public List<String> keys(String pattern) throws JedisException {
|
||||
public List<String> keys(String pattern) {
|
||||
client.keys(pattern);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public String randomKey() throws JedisException {
|
||||
public String randomKey() {
|
||||
client.randomKey();
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public String rename(String oldkey, String newkey) throws JedisException {
|
||||
public String rename(String oldkey, String newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int renamenx(String oldkey, String newkey) throws JedisException {
|
||||
public int renamenx(String oldkey, String newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int dbSize() throws JedisException {
|
||||
public int dbSize() {
|
||||
client.dbSize();
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int expire(String key, int seconds) throws JedisException {
|
||||
public int expire(String key, int seconds) {
|
||||
client.expire(key, seconds);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int expireAt(String key, long unixTime) throws JedisException {
|
||||
public int expireAt(String key, long unixTime) {
|
||||
client.expireAt(key, unixTime);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int ttl(String key) throws JedisException {
|
||||
public int ttl(String key) {
|
||||
client.ttl(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String select(int index) throws JedisException {
|
||||
public String select(int index) {
|
||||
client.select(index);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int move(String key, int dbIndex) throws JedisException {
|
||||
public int move(String key, int dbIndex) {
|
||||
client.move(key, dbIndex);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String flushAll() throws JedisException {
|
||||
public String flushAll() {
|
||||
client.flushAll();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String getSet(String key, String value) throws JedisException {
|
||||
public String getSet(String key, String value) {
|
||||
client.getSet(key, value);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public List<String> mget(String... keys) throws JedisException {
|
||||
public List<String> mget(String... keys) {
|
||||
client.mget(keys);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public int setnx(String key, String value) throws JedisException {
|
||||
public int setnx(String key, String value) {
|
||||
client.setnx(key, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String setex(String key, int seconds, String value)
|
||||
throws JedisException {
|
||||
public String setex(String key, int seconds, String value) {
|
||||
client.setex(key, seconds, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String mset(String... keysvalues) throws JedisException {
|
||||
public String mset(String... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int msetnx(String... keysvalues) throws JedisException {
|
||||
public int msetnx(String... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int decrBy(String key, int integer) throws JedisException {
|
||||
public int decrBy(String key, int integer) {
|
||||
client.decrBy(key, integer);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int decr(String key) throws JedisException {
|
||||
public int decr(String key) {
|
||||
client.decr(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int incrBy(String key, int integer) throws JedisException {
|
||||
public int incrBy(String key, int integer) {
|
||||
client.incrBy(key, integer);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int incr(String key) throws JedisException {
|
||||
public int incr(String key) {
|
||||
client.incr(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int append(String key, String value) throws JedisException {
|
||||
public int append(String key, String value) {
|
||||
client.append(key, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String substr(String key, int start, int end) throws JedisException {
|
||||
public String substr(String key, int start, int end) {
|
||||
client.substr(key, start, end);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int hset(String key, String field, String value)
|
||||
throws JedisException {
|
||||
public int hset(String key, String field, String value) {
|
||||
client.hset(key, field, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String hget(String key, String field) throws JedisException {
|
||||
public String hget(String key, String field) {
|
||||
client.hget(key, field);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int hsetnx(String key, String field, String value)
|
||||
throws JedisException {
|
||||
public int hsetnx(String key, String field, String value) {
|
||||
client.hsetnx(key, field, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String hmset(String key, Map<String, String> hash)
|
||||
throws JedisException {
|
||||
public String hmset(String key, Map<String, String> hash) {
|
||||
client.hmset(key, hash);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public List<String> hmget(String key, String... fields)
|
||||
throws JedisException {
|
||||
public List<String> hmget(String key, String... fields) {
|
||||
client.hmget(key, fields);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public int hincrBy(String key, String field, int value)
|
||||
throws JedisException {
|
||||
public int hincrBy(String key, String field, int value) {
|
||||
client.hincrBy(key, field, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int hexists(String key, String field) throws JedisException {
|
||||
public int hexists(String key, String field) {
|
||||
client.hexists(key, field);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int hdel(String key, String field) throws JedisException {
|
||||
public int hdel(String key, String field) {
|
||||
client.hdel(key, field);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int hlen(String key) throws JedisException {
|
||||
public int hlen(String key) {
|
||||
client.hlen(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public List<String> hkeys(String key) throws JedisException {
|
||||
public List<String> hkeys(String key) {
|
||||
client.hkeys(key);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public List<String> hvals(String key) throws JedisException {
|
||||
public List<String> hvals(String key) {
|
||||
client.hvals(key);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public Map<String, String> hgetAll(String key) throws JedisException {
|
||||
public Map<String, String> hgetAll(String key) {
|
||||
client.hgetAll(key);
|
||||
List<String> flatHash = client.getMultiBulkReply();
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
@@ -248,182 +242,174 @@ public class Jedis {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public int rpush(String key, String string) throws JedisException {
|
||||
public int rpush(String key, String string) {
|
||||
client.rpush(key, string);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int lpush(String key, String string) throws JedisException {
|
||||
public int lpush(String key, String string) {
|
||||
client.lpush(key, string);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int llen(String key) throws JedisException {
|
||||
public int llen(String key) {
|
||||
client.llen(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public List<String> lrange(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public List<String> lrange(String key, int start, int end) {
|
||||
client.lrange(key, start, end);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public String ltrim(String key, int start, int end) throws JedisException {
|
||||
public String ltrim(String key, int start, int end) {
|
||||
client.ltrim(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lindex(String key, int index) throws JedisException {
|
||||
public String lindex(String key, int index) {
|
||||
client.lindex(key, index);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public String lset(String key, int index, String value)
|
||||
throws JedisException {
|
||||
public String lset(String key, int index, String value) {
|
||||
client.lset(key, index, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int lrem(String key, int count, String value) throws JedisException {
|
||||
public int lrem(String key, int count, String value) {
|
||||
client.lrem(key, count, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String lpop(String key) throws JedisException {
|
||||
public String lpop(String key) {
|
||||
client.lpop(key);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public String rpop(String key) throws JedisException {
|
||||
public String rpop(String key) {
|
||||
client.rpop(key);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public String rpoplpush(String srckey, String dstkey) throws JedisException {
|
||||
public String rpoplpush(String srckey, String dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int sadd(String key, String member) throws JedisException {
|
||||
public int sadd(String key, String member) {
|
||||
client.sadd(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> smembers(String key) throws JedisException {
|
||||
public Set<String> smembers(String key) {
|
||||
client.smembers(key);
|
||||
List<String> members = client.getMultiBulkReply();
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int srem(String key, String member) throws JedisException {
|
||||
public int srem(String key, String member) {
|
||||
client.srem(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String spop(String key) throws JedisException {
|
||||
public String spop(String key) {
|
||||
client.spop(key);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int smove(String srckey, String dstkey, String member)
|
||||
throws JedisException {
|
||||
public int smove(String srckey, String dstkey, String member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int scard(String key) throws JedisException {
|
||||
public int scard(String key) {
|
||||
client.scard(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int sismember(String key, String member) throws JedisException {
|
||||
public int sismember(String key, String member) {
|
||||
client.sismember(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> sinter(String... keys) throws JedisException {
|
||||
public Set<String> sinter(String... keys) {
|
||||
client.sinter(keys);
|
||||
List<String> members = client.getMultiBulkReply();
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int sinterstore(String dstkey, String... keys) throws JedisException {
|
||||
public int sinterstore(String dstkey, String... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> sunion(String... keys) throws JedisException {
|
||||
public Set<String> sunion(String... keys) {
|
||||
client.sunion(keys);
|
||||
List<String> members = client.getMultiBulkReply();
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int sunionstore(String dstkey, String... keys) throws JedisException {
|
||||
public int sunionstore(String dstkey, String... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> sdiff(String... keys) throws JedisException {
|
||||
public Set<String> sdiff(String... keys) {
|
||||
client.sdiff(keys);
|
||||
List<String> members = client.getMultiBulkReply();
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int sdiffstore(String dstkey, String... keys) throws JedisException {
|
||||
public int sdiffstore(String dstkey, String... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public String srandmember(String key) throws JedisException {
|
||||
public String srandmember(String key) {
|
||||
client.srandmember(key);
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int zadd(String key, double score, String member)
|
||||
throws JedisException {
|
||||
public int zadd(String key, double score, String member) {
|
||||
client.zadd(key, score, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> zrange(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public Set<String> zrange(String key, int start, int end) {
|
||||
client.zrange(key, start, end);
|
||||
List<String> members = client.getMultiBulkReply();
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int zrem(String key, String member) throws JedisException {
|
||||
public int zrem(String key, String member) {
|
||||
client.zrem(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public double zincrby(String key, double score, String member)
|
||||
throws JedisException {
|
||||
public double zincrby(String key, double score, String member) {
|
||||
client.zincrby(key, score, member);
|
||||
String newscore = client.getBulkReply();
|
||||
return Double.valueOf(newscore);
|
||||
}
|
||||
|
||||
public int zrank(String key, String member) throws JedisException {
|
||||
public int zrank(String key, String member) {
|
||||
client.zrank(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zrevrank(String key, String member) throws JedisException {
|
||||
public int zrevrank(String key, String member) {
|
||||
client.zrevrank(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Set<String> zrevrange(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public Set<String> zrevrange(String key, int start, int end) {
|
||||
client.zrevrange(key, start, end);
|
||||
List<String> members = client.getMultiBulkReply();
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public Set<Tuple> zrangeWithScores(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public Set<Tuple> zrangeWithScores(String key, int start, int end) {
|
||||
client.zrangeWithScores(key, start, end);
|
||||
List<String> membersWithScores = client.getMultiBulkReply();
|
||||
Set<Tuple> set = new LinkedHashSet<Tuple>();
|
||||
@@ -436,8 +422,7 @@ public class Jedis {
|
||||
return set;
|
||||
}
|
||||
|
||||
public Set<Tuple> zrevrangeWithScores(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public Set<Tuple> zrevrangeWithScores(String key, int start, int end) {
|
||||
client.zrevrangeWithScores(key, start, end);
|
||||
List<String> membersWithScores = client.getMultiBulkReply();
|
||||
Set<Tuple> set = new LinkedHashSet<Tuple>();
|
||||
@@ -450,25 +435,24 @@ public class Jedis {
|
||||
return set;
|
||||
}
|
||||
|
||||
public int zcard(String key) throws JedisException {
|
||||
public int zcard(String key) {
|
||||
client.zcard(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public double zscore(String key, String member) throws JedisException {
|
||||
public double zscore(String key, String member) {
|
||||
client.zscore(key, member);
|
||||
String score = client.getBulkReply();
|
||||
return Double.valueOf(score);
|
||||
}
|
||||
|
||||
public Transaction multi() throws JedisException {
|
||||
public Transaction multi() {
|
||||
client.multi();
|
||||
client.getStatusCodeReply();
|
||||
return new Transaction(client);
|
||||
}
|
||||
|
||||
public List<Object> multi(TransactionBlock jedisTransaction)
|
||||
throws JedisException {
|
||||
public List<Object> multi(TransactionBlock jedisTransaction) {
|
||||
try {
|
||||
jedisTransaction.setClient(client);
|
||||
multi();
|
||||
@@ -487,29 +471,27 @@ public class Jedis {
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
public String watch(String key) throws JedisException {
|
||||
public String watch(String key) {
|
||||
client.watch(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String unwatch() throws JedisException {
|
||||
public String unwatch() {
|
||||
client.unwatch();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public List<String> sort(String key) throws JedisException {
|
||||
public List<String> sort(String key) {
|
||||
client.sort(key);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public List<String> sort(String key, SortingParams sortingParameters)
|
||||
throws JedisException {
|
||||
public List<String> sort(String key, SortingParams sortingParameters) {
|
||||
client.sort(key, sortingParameters);
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public List<String> blpop(int timeout, String... keys)
|
||||
throws JedisException {
|
||||
public List<String> blpop(int timeout, String... keys) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
for (String arg : keys) {
|
||||
args.add(arg);
|
||||
@@ -520,19 +502,17 @@ public class Jedis {
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public int sort(String key, SortingParams sortingParameters, String dstkey)
|
||||
throws JedisException {
|
||||
public int sort(String key, SortingParams sortingParameters, String dstkey) {
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int sort(String key, String dstkey) throws JedisException {
|
||||
public int sort(String key, String dstkey) {
|
||||
client.sort(key, dstkey);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public List<String> brpop(int timeout, String... keys)
|
||||
throws JedisException {
|
||||
public List<String> brpop(int timeout, String... keys) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
for (String arg : keys) {
|
||||
args.add(arg);
|
||||
@@ -543,7 +523,7 @@ public class Jedis {
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public String auth(String password) throws JedisException {
|
||||
public String auth(String password) {
|
||||
client.auth(password);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
public class JedisException extends Exception {
|
||||
import java.io.IOException;
|
||||
|
||||
public class JedisException extends RuntimeException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -9,4 +11,8 @@ public class JedisException extends Exception {
|
||||
public JedisException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public JedisException(IOException e) {
|
||||
super(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ public class Protocol {
|
||||
try {
|
||||
os.write(builder.toString().getBytes());
|
||||
} catch (IOException e) {
|
||||
// TODO don't know what to do here!
|
||||
throw new JedisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void processError(InputStream is) throws JedisException {
|
||||
public void processError(InputStream is) {
|
||||
String message = readLine(is);
|
||||
throw new JedisException(message);
|
||||
}
|
||||
@@ -60,27 +60,27 @@ public class Protocol {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Dont know what to do here!
|
||||
throw new JedisException(e);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getBulkReply(InputStream is) throws JedisException {
|
||||
public String getBulkReply(InputStream is) {
|
||||
Object reply = process(is);
|
||||
return (String) reply;
|
||||
}
|
||||
|
||||
public String getStatusCodeReply(InputStream is) throws JedisException {
|
||||
public String getStatusCodeReply(InputStream is) {
|
||||
Object reply = process(is);
|
||||
return (String) reply;
|
||||
}
|
||||
|
||||
public int getIntegerReply(InputStream is) throws JedisException {
|
||||
public int getIntegerReply(InputStream is) {
|
||||
Object reply = process(is);
|
||||
return (Integer) reply;
|
||||
}
|
||||
|
||||
private Object process(InputStream is) throws JedisException {
|
||||
private Object process(InputStream is) {
|
||||
try {
|
||||
byte b = (byte) is.read();
|
||||
if (b == MINUS_BYTE) {
|
||||
@@ -95,8 +95,7 @@ public class Protocol {
|
||||
return processStatusCodeReply(is);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO check what to do here
|
||||
throw new JedisException(e.getMessage());
|
||||
throw new JedisException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -107,16 +106,20 @@ public class Protocol {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Object processBulkReply(InputStream is) throws IOException {
|
||||
private Object processBulkReply(InputStream is) {
|
||||
int len = Integer.parseInt(readLine(is));
|
||||
if (len == -1) {
|
||||
return null;
|
||||
}
|
||||
byte[] read = new byte[len];
|
||||
is.read(read);
|
||||
// read 2 more bytes for the command delimiter
|
||||
is.read();
|
||||
is.read();
|
||||
try {
|
||||
is.read(read);
|
||||
// read 2 more bytes for the command delimiter
|
||||
is.read();
|
||||
is.read();
|
||||
} catch (IOException e) {
|
||||
throw new JedisException(e);
|
||||
}
|
||||
|
||||
return new String(read);
|
||||
}
|
||||
@@ -128,7 +131,7 @@ public class Protocol {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Object processMultiBulkReply(InputStream is) throws JedisException {
|
||||
private Object processMultiBulkReply(InputStream is) {
|
||||
int num = Integer.parseInt(readLine(is));
|
||||
if (num == -1) {
|
||||
return null;
|
||||
@@ -141,7 +144,7 @@ public class Protocol {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> getMultiBulkReply(InputStream is) throws JedisException {
|
||||
public List<Object> getMultiBulkReply(InputStream is) {
|
||||
Object reply = process(is);
|
||||
List<Object> ret = (List<Object>) reply;
|
||||
return ret;
|
||||
|
||||
@@ -13,413 +13,397 @@ public class Transaction {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public String ping() throws JedisException {
|
||||
public String ping() {
|
||||
client.ping();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String set(String key, String value) throws JedisException {
|
||||
public String set(String key, String value) {
|
||||
client.set(key, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String get(String key) throws JedisException {
|
||||
public String get(String key) {
|
||||
client.sendCommand("GET", key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String exists(String key) throws JedisException {
|
||||
public String exists(String key) {
|
||||
client.exists(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String del(String... keys) throws JedisException {
|
||||
public String del(String... keys) {
|
||||
client.del(keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String type(String key) throws JedisException {
|
||||
public String type(String key) {
|
||||
client.type(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String flushDB() throws JedisException {
|
||||
public String flushDB() {
|
||||
client.flushDB();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String keys(String pattern) throws JedisException {
|
||||
public String keys(String pattern) {
|
||||
client.keys(pattern);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String randomKey() throws JedisException {
|
||||
public String randomKey() {
|
||||
client.randomKey();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String rename(String oldkey, String newkey) throws JedisException {
|
||||
public String rename(String oldkey, String newkey) {
|
||||
client.rename(oldkey, newkey);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String renamenx(String oldkey, String newkey) throws JedisException {
|
||||
public String renamenx(String oldkey, String newkey) {
|
||||
client.renamenx(oldkey, newkey);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String dbSize() throws JedisException {
|
||||
public String dbSize() {
|
||||
client.dbSize();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String expire(String key, int seconds) throws JedisException {
|
||||
public String expire(String key, int seconds) {
|
||||
client.expire(key, seconds);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String expireAt(String key, long unixTime) throws JedisException {
|
||||
public String expireAt(String key, long unixTime) {
|
||||
client.expireAt(key, unixTime);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String ttl(String key) throws JedisException {
|
||||
public String ttl(String key) {
|
||||
client.ttl(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String select(int index) throws JedisException {
|
||||
public String select(int index) {
|
||||
client.select(index);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String move(String key, int dbIndex) throws JedisException {
|
||||
public String move(String key, int dbIndex) {
|
||||
client.move(key, dbIndex);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String flushAll() throws JedisException {
|
||||
public String flushAll() {
|
||||
client.flushAll();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String getSet(String key, String value) throws JedisException {
|
||||
public String getSet(String key, String value) {
|
||||
client.getSet(key, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String mget(String... keys) throws JedisException {
|
||||
public String mget(String... keys) {
|
||||
client.mget(keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String setnx(String key, String value) throws JedisException {
|
||||
public String setnx(String key, String value) {
|
||||
client.setnx(key, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String setex(String key, int seconds, String value)
|
||||
throws JedisException {
|
||||
public String setex(String key, int seconds, String value) {
|
||||
client.setex(key, seconds, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String mset(String... keysvalues) throws JedisException {
|
||||
public String mset(String... keysvalues) {
|
||||
client.mset(keysvalues);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String msetnx(String... keysvalues) throws JedisException {
|
||||
public String msetnx(String... keysvalues) {
|
||||
client.msetnx(keysvalues);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String decrBy(String key, int integer) throws JedisException {
|
||||
public String decrBy(String key, int integer) {
|
||||
client.decrBy(key, integer);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String decr(String key) throws JedisException {
|
||||
public String decr(String key) {
|
||||
client.decr(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String incrBy(String key, int integer) throws JedisException {
|
||||
public String incrBy(String key, int integer) {
|
||||
client.incrBy(key, integer);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String incr(String key) throws JedisException {
|
||||
public String incr(String key) {
|
||||
client.incr(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String append(String key, String value) throws JedisException {
|
||||
public String append(String key, String value) {
|
||||
client.append(key, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String substr(String key, int start, int end) throws JedisException {
|
||||
public String substr(String key, int start, int end) {
|
||||
client.substr(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hset(String key, String field, String value)
|
||||
throws JedisException {
|
||||
public String hset(String key, String field, String value) {
|
||||
client.hset(key, field, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hget(String key, String field) throws JedisException {
|
||||
public String hget(String key, String field) {
|
||||
client.hget(key, field);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hsetnx(String key, String field, String value)
|
||||
throws JedisException {
|
||||
public String hsetnx(String key, String field, String value) {
|
||||
client.hsetnx(key, field, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hmset(String key, Map<String, String> hash)
|
||||
throws JedisException {
|
||||
public String hmset(String key, Map<String, String> hash) {
|
||||
client.hmset(key, hash);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hmget(String key, String... fields) throws JedisException {
|
||||
public String hmget(String key, String... fields) {
|
||||
client.hmget(key, fields);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hincrBy(String key, String field, int value)
|
||||
throws JedisException {
|
||||
public String hincrBy(String key, String field, int value) {
|
||||
client.hincrBy(key, field, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hexists(String key, String field) throws JedisException {
|
||||
public String hexists(String key, String field) {
|
||||
client.hexists(key, field);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hdel(String key, String field) throws JedisException {
|
||||
public String hdel(String key, String field) {
|
||||
client.hdel(key, field);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hlen(String key) throws JedisException {
|
||||
public String hlen(String key) {
|
||||
client.hlen(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hkeys(String key) throws JedisException {
|
||||
public String hkeys(String key) {
|
||||
client.hkeys(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hvals(String key) throws JedisException {
|
||||
public String hvals(String key) {
|
||||
client.hvals(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String hgetAll(String key) throws JedisException {
|
||||
public String hgetAll(String key) {
|
||||
client.hgetAll(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String rpush(String key, String string) throws JedisException {
|
||||
public String rpush(String key, String string) {
|
||||
client.rpush(key, string);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lpush(String key, String string) throws JedisException {
|
||||
public String lpush(String key, String string) {
|
||||
client.lpush(key, string);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String llen(String key) throws JedisException {
|
||||
public String llen(String key) {
|
||||
client.llen(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lrange(String key, int start, int end) throws JedisException {
|
||||
public String lrange(String key, int start, int end) {
|
||||
client.lrange(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String ltrim(String key, int start, int end) throws JedisException {
|
||||
public String ltrim(String key, int start, int end) {
|
||||
client.ltrim(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lindex(String key, int index) throws JedisException {
|
||||
public String lindex(String key, int index) {
|
||||
client.lindex(key, index);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lset(String key, int index, String value)
|
||||
throws JedisException {
|
||||
public String lset(String key, int index, String value) {
|
||||
client.lset(key, index, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lrem(String key, int count, String value)
|
||||
throws JedisException {
|
||||
public String lrem(String key, int count, String value) {
|
||||
client.lrem(key, count, value);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String lpop(String key) throws JedisException {
|
||||
public String lpop(String key) {
|
||||
client.lpop(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String rpop(String key) throws JedisException {
|
||||
public String rpop(String key) {
|
||||
client.rpop(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String rpoplpush(String srckey, String dstkey) throws JedisException {
|
||||
public String rpoplpush(String srckey, String dstkey) {
|
||||
client.rpoplpush(srckey, dstkey);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sadd(String key, String member) throws JedisException {
|
||||
public String sadd(String key, String member) {
|
||||
client.sadd(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String smembers(String key) throws JedisException {
|
||||
public String smembers(String key) {
|
||||
client.smembers(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String srem(String key, String member) throws JedisException {
|
||||
public String srem(String key, String member) {
|
||||
client.srem(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String spop(String key) throws JedisException {
|
||||
public String spop(String key) {
|
||||
client.spop(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String smove(String srckey, String dstkey, String member)
|
||||
throws JedisException {
|
||||
public String smove(String srckey, String dstkey, String member) {
|
||||
client.smove(srckey, dstkey, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String scard(String key) throws JedisException {
|
||||
public String scard(String key) {
|
||||
client.scard(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sismember(String key, String member) throws JedisException {
|
||||
public String sismember(String key, String member) {
|
||||
client.sismember(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sinter(String... keys) throws JedisException {
|
||||
public String sinter(String... keys) {
|
||||
client.sinter(keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sinterstore(String dstkey, String... keys)
|
||||
throws JedisException {
|
||||
public String sinterstore(String dstkey, String... keys) {
|
||||
client.sinterstore(dstkey, keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sunion(String... keys) throws JedisException {
|
||||
public String sunion(String... keys) {
|
||||
client.sunion(keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sunionstore(String dstkey, String... keys)
|
||||
throws JedisException {
|
||||
public String sunionstore(String dstkey, String... keys) {
|
||||
client.sunionstore(dstkey, keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sdiff(String... keys) throws JedisException {
|
||||
public String sdiff(String... keys) {
|
||||
client.sdiff(keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String sdiffstore(String dstkey, String... keys)
|
||||
throws JedisException {
|
||||
public String sdiffstore(String dstkey, String... keys) {
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String srandmember(String key) throws JedisException {
|
||||
public String srandmember(String key) {
|
||||
client.srandmember(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zadd(String key, double score, String member)
|
||||
throws JedisException {
|
||||
public String zadd(String key, double score, String member) {
|
||||
client.zadd(key, score, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrange(String key, int start, int end) throws JedisException {
|
||||
public String zrange(String key, int start, int end) {
|
||||
client.zrange(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrem(String key, String member) throws JedisException {
|
||||
public String zrem(String key, String member) {
|
||||
client.zrem(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zincrby(String key, double score, String member)
|
||||
throws JedisException {
|
||||
public String zincrby(String key, double score, String member) {
|
||||
client.zincrby(key, score, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrank(String key, String member) throws JedisException {
|
||||
public String zrank(String key, String member) {
|
||||
client.zrank(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrevrank(String key, String member) throws JedisException {
|
||||
public String zrevrank(String key, String member) {
|
||||
client.zrevrank(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrevrange(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public String zrevrange(String key, int start, int end) {
|
||||
client.zrevrange(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrangeWithScores(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public String zrangeWithScores(String key, int start, int end) {
|
||||
client.zrangeWithScores(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zrevrangeWithScores(String key, int start, int end)
|
||||
throws JedisException {
|
||||
public String zrevrangeWithScores(String key, int start, int end) {
|
||||
client.zrevrangeWithScores(key, start, end);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zcard(String key) throws JedisException {
|
||||
public String zcard(String key) {
|
||||
client.zcard(key);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String zscore(String key, String member) throws JedisException {
|
||||
public String zscore(String key, String member) {
|
||||
client.zscore(key, member);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public List<Object> exec() throws JedisException {
|
||||
public List<Object> exec() {
|
||||
client.exec();
|
||||
return client.getObjectMultiBulkReply();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class JedisTest {
|
||||
@Test(expected = JedisException.class)
|
||||
public void useWithoutConnecting() throws JedisException {
|
||||
public void useWithoutConnecting() {
|
||||
Jedis jedis = new Jedis("localhost");
|
||||
jedis.dbSize();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Protocol;
|
||||
|
||||
public class ProtocolTest extends Assert {
|
||||
@@ -39,7 +38,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bulkReply() throws JedisException {
|
||||
public void bulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = protocol.getBulkReply(is);
|
||||
@@ -47,7 +46,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullBulkReply() throws JedisException {
|
||||
public void nullBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = protocol.getBulkReply(is);
|
||||
@@ -55,7 +54,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleLineReply() throws JedisException {
|
||||
public void singleLineReply() {
|
||||
InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = protocol.getStatusCodeReply(is);
|
||||
@@ -63,7 +62,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integerReply() throws JedisException {
|
||||
public void integerReply() {
|
||||
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
int response = protocol.getIntegerReply(is);
|
||||
@@ -72,7 +71,7 @@ public class ProtocolTest extends Assert {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void multiBulkReply() throws JedisException {
|
||||
public void multiBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream(
|
||||
"*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n"
|
||||
.getBytes());
|
||||
@@ -106,7 +105,7 @@ public class ProtocolTest extends Assert {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void nullMultiBulkReply() throws JedisException {
|
||||
public void nullMultiBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
List<String> response = (List<String>) (List<?>) protocol
|
||||
|
||||
@@ -5,13 +5,12 @@ import java.net.UnknownHostException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class GetSetBenchmark {
|
||||
private static final int TOTAL_OPERATIONS = 100000;
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException,
|
||||
IOException, JedisException {
|
||||
IOException {
|
||||
Jedis jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
jedis.auth("foobared");
|
||||
|
||||
@@ -9,13 +9,13 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void ping() throws JedisException {
|
||||
public void ping() {
|
||||
String status = jedis.ping();
|
||||
assertEquals("PONG", status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exists() throws JedisException {
|
||||
public void exists() {
|
||||
String status = jedis.set("foo", "bar");
|
||||
assertEquals("OK", status);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void del() throws JedisException {
|
||||
public void del() {
|
||||
jedis.set("foo1", "bar1");
|
||||
jedis.set("foo2", "bar2");
|
||||
jedis.set("foo3", "bar3");
|
||||
@@ -55,14 +55,14 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void type() throws JedisException {
|
||||
public void type() {
|
||||
jedis.set("foo", "bar");
|
||||
String status = jedis.type("foo");
|
||||
assertEquals("string", status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keys() throws JedisException {
|
||||
public void keys() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.set("foobar", "bar");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void randomKey() throws JedisException {
|
||||
public void randomKey() {
|
||||
assertEquals(null, jedis.randomKey());
|
||||
|
||||
jedis.set("foo", "bar");
|
||||
@@ -93,7 +93,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rename() throws JedisException {
|
||||
public void rename() {
|
||||
jedis.set("foo", "bar");
|
||||
String status = jedis.rename("foo", "bar");
|
||||
assertEquals("OK", status);
|
||||
@@ -106,13 +106,13 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void renameOldAndNewAreTheSame() throws JedisException {
|
||||
public void renameOldAndNewAreTheSame() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.rename("foo", "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renamenx() throws JedisException {
|
||||
public void renamenx() {
|
||||
jedis.set("foo", "bar");
|
||||
int status = jedis.renamenx("foo", "bar");
|
||||
assertEquals(1, status);
|
||||
@@ -123,7 +123,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dbSize() throws JedisException {
|
||||
public void dbSize() {
|
||||
int size = jedis.dbSize();
|
||||
assertEquals(0, size);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expire() throws JedisException {
|
||||
public void expire() {
|
||||
int status = jedis.expire("foo", 20);
|
||||
assertEquals(0, status);
|
||||
|
||||
@@ -146,7 +146,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expireAt() throws JedisException {
|
||||
public void expireAt() {
|
||||
long unixTime = (System.currentTimeMillis() / 1000L) + 20;
|
||||
|
||||
int status = jedis.expireAt("foo", unixTime);
|
||||
@@ -163,7 +163,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ttl() throws JedisException {
|
||||
public void ttl() {
|
||||
int ttl = jedis.ttl("foo");
|
||||
assertEquals(-1, ttl);
|
||||
|
||||
@@ -177,7 +177,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void select() throws JedisException {
|
||||
public void select() {
|
||||
jedis.set("foo", "bar");
|
||||
String status = jedis.select(1);
|
||||
assertEquals("OK", status);
|
||||
@@ -188,7 +188,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void move() throws JedisException {
|
||||
public void move() {
|
||||
int status = jedis.move("foo", 1);
|
||||
assertEquals(0, status);
|
||||
|
||||
@@ -202,7 +202,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flushDB() throws JedisException {
|
||||
public void flushDB() {
|
||||
jedis.set("foo", "bar");
|
||||
assertEquals(1, jedis.dbSize());
|
||||
jedis.set("bar", "foo");
|
||||
@@ -215,7 +215,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flushAll() throws JedisException {
|
||||
public void flushAll() {
|
||||
jedis.set("foo", "bar");
|
||||
assertEquals(1, jedis.dbSize());
|
||||
jedis.set("bar", "foo");
|
||||
|
||||
@@ -2,11 +2,9 @@ package redis.clients.jedis.tests.commands;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class ConnectionHandlingCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void quit() throws JedisException {
|
||||
public void quit() {
|
||||
jedis.quit();
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,9 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void hset() throws JedisException {
|
||||
public void hset() {
|
||||
int status = jedis.hset("foo", "bar", "car");
|
||||
assertEquals(1, status);
|
||||
status = jedis.hset("foo", "bar", "foo");
|
||||
@@ -20,7 +18,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hget() throws JedisException {
|
||||
public void hget() {
|
||||
jedis.hset("foo", "bar", "car");
|
||||
assertEquals(null, jedis.hget("bar", "foo"));
|
||||
assertEquals(null, jedis.hget("foo", "car"));
|
||||
@@ -28,7 +26,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hsetnx() throws JedisException {
|
||||
public void hsetnx() {
|
||||
int status = jedis.hsetnx("foo", "bar", "car");
|
||||
assertEquals(1, status);
|
||||
assertEquals("car", jedis.hget("foo", "bar"));
|
||||
@@ -43,7 +41,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmset() throws JedisException {
|
||||
public void hmset() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -54,7 +52,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmget() throws JedisException {
|
||||
public void hmget() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -70,7 +68,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hincrBy() throws JedisException {
|
||||
public void hincrBy() {
|
||||
int value = jedis.hincrBy("foo", "bar", 1);
|
||||
assertEquals(1, value);
|
||||
value = jedis.hincrBy("foo", "bar", -1);
|
||||
@@ -80,7 +78,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hexists() throws JedisException {
|
||||
public void hexists() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -92,7 +90,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hdel() throws JedisException {
|
||||
public void hdel() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -105,7 +103,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hlen() throws JedisException {
|
||||
public void hlen() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -116,7 +114,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hkeys() throws JedisException {
|
||||
public void hkeys() {
|
||||
Map<String, String> hash = new LinkedHashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -130,7 +128,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hvals() throws JedisException {
|
||||
public void hvals() {
|
||||
Map<String, String> hash = new LinkedHashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -144,7 +142,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hgetAll() throws JedisException {
|
||||
public void hgetAll() {
|
||||
Map<String, String> h = new HashMap<String, String>();
|
||||
h.put("bar", "car");
|
||||
h.put("car", "bar");
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.junit.Before;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class JedisCommandTestBase extends Assert {
|
||||
public abstract class JedisCommandTestBase extends Assert {
|
||||
|
||||
protected Jedis jedis;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class ListCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void rpush() throws JedisException {
|
||||
public void rpush() {
|
||||
int size = jedis.rpush("foo", "bar");
|
||||
assertEquals(1, size);
|
||||
size = jedis.rpush("foo", "foo");
|
||||
@@ -18,7 +18,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lpush() throws JedisException {
|
||||
public void lpush() {
|
||||
int size = jedis.lpush("foo", "bar");
|
||||
assertEquals(1, size);
|
||||
size = jedis.lpush("foo", "foo");
|
||||
@@ -26,7 +26,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void llen() throws JedisException {
|
||||
public void llen() {
|
||||
assertEquals(0, jedis.llen("foo"));
|
||||
jedis.lpush("foo", "bar");
|
||||
jedis.lpush("foo", "car");
|
||||
@@ -34,13 +34,13 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void llenNotOnList() throws JedisException {
|
||||
public void llenNotOnList() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.llen("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lrange() throws JedisException {
|
||||
public void lrange() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -69,7 +69,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ltrim() throws JedisException {
|
||||
public void ltrim() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
@@ -85,7 +85,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lindex() throws JedisException {
|
||||
public void lindex() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
@@ -102,7 +102,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lset() throws JedisException {
|
||||
public void lset() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
@@ -112,7 +112,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lrem() throws JedisException {
|
||||
public void lrem() {
|
||||
jedis.lpush("foo", "hello");
|
||||
jedis.lpush("foo", "hello");
|
||||
jedis.lpush("foo", "x");
|
||||
@@ -136,7 +136,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lpop() throws JedisException {
|
||||
public void lpop() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -157,7 +157,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rpop() throws JedisException {
|
||||
public void rpop() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -178,7 +178,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rpoplpush() throws JedisException {
|
||||
public void rpoplpush() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -204,7 +204,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void blpop() throws JedisException {
|
||||
public void blpop() {
|
||||
List<String> result = jedis.blpop(2, "foo");
|
||||
assertNull(result);
|
||||
|
||||
@@ -226,7 +226,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void brpop() throws JedisException {
|
||||
public void brpop() {
|
||||
List<String> result = jedis.brpop(2, "foo");
|
||||
assertNull(result);
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class SetCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void sadd() throws JedisException {
|
||||
public void sadd() {
|
||||
int status = jedis.sadd("foo", "a");
|
||||
assertEquals(1, status);
|
||||
|
||||
@@ -18,7 +16,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smembers() throws JedisException {
|
||||
public void smembers() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -32,7 +30,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void srem() throws JedisException {
|
||||
public void srem() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -50,7 +48,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void spop() throws JedisException {
|
||||
public void spop() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -64,7 +62,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smove() throws JedisException {
|
||||
public void smove() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -88,7 +86,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scard() throws JedisException {
|
||||
public void scard() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -101,7 +99,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sismember() throws JedisException {
|
||||
public void sismember() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -113,7 +111,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sinter() throws JedisException {
|
||||
public void sinter() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -128,7 +126,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sinterstore() throws JedisException {
|
||||
public void sinterstore() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -145,7 +143,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sunion() throws JedisException {
|
||||
public void sunion() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -162,7 +160,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sunionstore() throws JedisException {
|
||||
public void sunionstore() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -181,7 +179,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sdiff() throws JedisException {
|
||||
public void sdiff() {
|
||||
jedis.sadd("foo", "x");
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
@@ -201,7 +199,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sdiffstore() throws JedisException {
|
||||
public void sdiffstore() {
|
||||
jedis.sadd("foo", "x");
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
@@ -222,7 +220,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void srandmember() throws JedisException {
|
||||
public void srandmember() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Tuple;
|
||||
|
||||
public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void zadd() throws JedisException {
|
||||
public void zadd() {
|
||||
int status = jedis.zadd("foo", 1d, "a");
|
||||
assertEquals(1, status);
|
||||
|
||||
@@ -25,7 +24,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrange() throws JedisException {
|
||||
public void zrange() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -44,7 +43,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrevrange() throws JedisException {
|
||||
public void zrevrange() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -63,7 +62,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrem() throws JedisException {
|
||||
public void zrem() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -81,7 +80,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zincrby() throws JedisException {
|
||||
public void zincrby() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -96,7 +95,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrank() throws JedisException {
|
||||
public void zrank() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -108,7 +107,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrevrank() throws JedisException {
|
||||
public void zrevrank() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -120,7 +119,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrangeWithScores() throws JedisException {
|
||||
public void zrangeWithScores() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -139,7 +138,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrevrangeWithScores() throws JedisException {
|
||||
public void zrevrangeWithScores() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -158,7 +157,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zcard() throws JedisException {
|
||||
public void zcard() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -169,7 +168,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zscore() throws JedisException {
|
||||
public void zscore() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
|
||||
@@ -5,12 +5,11 @@ import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.SortingParams;
|
||||
|
||||
public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void sort() throws JedisException {
|
||||
public void sort() {
|
||||
jedis.lpush("foo", "3");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "1");
|
||||
@@ -26,7 +25,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortBy() throws JedisException {
|
||||
public void sortBy() {
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
jedis.lpush("foo", "1");
|
||||
@@ -49,7 +48,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortDesc() throws JedisException {
|
||||
public void sortDesc() {
|
||||
jedis.lpush("foo", "3");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "1");
|
||||
@@ -68,7 +67,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortLimit() throws JedisException {
|
||||
public void sortLimit() {
|
||||
for (int n = 10; n > 0; n--) {
|
||||
jedis.lpush("foo", String.valueOf(n));
|
||||
}
|
||||
@@ -87,7 +86,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortAlpha() throws JedisException {
|
||||
public void sortAlpha() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "10");
|
||||
@@ -106,7 +105,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortGet() throws JedisException {
|
||||
public void sortGet() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "10");
|
||||
@@ -136,7 +135,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortStore() throws JedisException {
|
||||
public void sortStore() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "10");
|
||||
|
||||
@@ -9,7 +9,7 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void setAndGet() throws JedisException {
|
||||
public void setAndGet() {
|
||||
String status = jedis.set("foo", "bar");
|
||||
assertEquals("OK", status);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSet() throws JedisException {
|
||||
public void getSet() {
|
||||
String value = jedis.getSet("foo", "bar");
|
||||
assertEquals(null, value);
|
||||
value = jedis.get("foo");
|
||||
@@ -28,7 +28,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mget() throws JedisException {
|
||||
public void mget() {
|
||||
List<String> values = jedis.mget("foo", "bar");
|
||||
List<String> expected = new ArrayList<String>();
|
||||
expected.add(null);
|
||||
@@ -56,7 +56,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setnx() throws JedisException {
|
||||
public void setnx() {
|
||||
int status = jedis.setnx("foo", "bar");
|
||||
assertEquals(1, status);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -67,7 +67,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setex() throws JedisException {
|
||||
public void setex() {
|
||||
String status = jedis.setex("foo", 20, "bar");
|
||||
assertEquals("OK", status);
|
||||
int ttl = jedis.ttl("foo");
|
||||
@@ -75,7 +75,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mset() throws JedisException {
|
||||
public void mset() {
|
||||
String status = jedis.mset("foo", "bar", "bar", "foo");
|
||||
assertEquals("OK", status);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -83,7 +83,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void msetnx() throws JedisException {
|
||||
public void msetnx() {
|
||||
int status = jedis.msetnx("foo", "bar", "bar", "foo");
|
||||
assertEquals(1, status);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -96,13 +96,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void incrWrongValue() throws JedisException {
|
||||
public void incrWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.incr("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incr() throws JedisException {
|
||||
public void incr() {
|
||||
int value = jedis.incr("foo");
|
||||
assertEquals(1, value);
|
||||
value = jedis.incr("foo");
|
||||
@@ -110,13 +110,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void incrByWrongValue() throws JedisException {
|
||||
public void incrByWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.incrBy("foo", 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incrBy() throws JedisException {
|
||||
public void incrBy() {
|
||||
int value = jedis.incrBy("foo", 2);
|
||||
assertEquals(2, value);
|
||||
value = jedis.incrBy("foo", 2);
|
||||
@@ -124,13 +124,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void decrWrongValue() throws JedisException {
|
||||
public void decrWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.decr("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decr() throws JedisException {
|
||||
public void decr() {
|
||||
int value = jedis.decr("foo");
|
||||
assertEquals(-1, value);
|
||||
value = jedis.decr("foo");
|
||||
@@ -138,13 +138,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void decrByWrongValue() throws JedisException {
|
||||
public void decrByWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.decrBy("foo", 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decrBy() throws JedisException {
|
||||
public void decrBy() {
|
||||
int value = jedis.decrBy("foo", 2);
|
||||
assertEquals(-2, value);
|
||||
value = jedis.decrBy("foo", 2);
|
||||
@@ -152,7 +152,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void append() throws JedisException {
|
||||
public void append() {
|
||||
int value = jedis.append("foo", "bar");
|
||||
assertEquals(3, value);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -162,7 +162,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void substr() throws JedisException {
|
||||
public void substr() {
|
||||
jedis.set("s", "This is a string");
|
||||
assertEquals("This", jedis.substr("s", 0, 3));
|
||||
assertEquals("ing", jedis.substr("s", -3, -1));
|
||||
|
||||
@@ -8,13 +8,12 @@ import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.TransactionBlock;
|
||||
|
||||
public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void multi() throws JedisException {
|
||||
public void multi() {
|
||||
Transaction trans = jedis.multi();
|
||||
|
||||
String status = trans.sadd("foo", "a");
|
||||
@@ -36,9 +35,9 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiBlock() throws JedisException {
|
||||
public void multiBlock() {
|
||||
List<Object> response = jedis.multi(new TransactionBlock() {
|
||||
public void execute() throws JedisException {
|
||||
public void execute() {
|
||||
String status = sadd("foo", "a");
|
||||
assertEquals("QUEUED", status);
|
||||
|
||||
@@ -58,8 +57,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void watch() throws JedisException, UnknownHostException,
|
||||
IOException {
|
||||
public void watch() throws UnknownHostException, IOException {
|
||||
jedis.watch("mykey");
|
||||
String val = jedis.get("mykey");
|
||||
val = "foo";
|
||||
@@ -77,8 +75,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unwatch() throws JedisException, UnknownHostException,
|
||||
IOException {
|
||||
public void unwatch() throws UnknownHostException, IOException {
|
||||
jedis.watch("mykey");
|
||||
String val = jedis.get("mykey");
|
||||
val = "foo";
|
||||
|
||||
Reference in New Issue
Block a user