Refactores primitive types in the API. Now int -> Integer and double -> Double.
This is to support Redis null values
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.util.RedisInputStream;
|
||||
import redis.clients.util.RedisOutputStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import redis.clients.util.RedisInputStream;
|
||||
import redis.clients.util.RedisOutputStream;
|
||||
|
||||
public class Connection {
|
||||
private String host;
|
||||
private int port = Protocol.DEFAULT_PORT;
|
||||
@@ -50,13 +50,13 @@ public class Connection {
|
||||
}
|
||||
|
||||
protected Connection sendCommand(String name, String... args) {
|
||||
try {
|
||||
connect();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new JedisException("Could not connect to redis-server", e);
|
||||
} catch (IOException e) {
|
||||
throw new JedisException("Could not connect to redis-server", e);
|
||||
}
|
||||
try {
|
||||
connect();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new JedisException("Could not connect to redis-server", e);
|
||||
} catch (IOException e) {
|
||||
throw new JedisException("Could not connect to redis-server", e);
|
||||
}
|
||||
protocol.sendCommand(outputStream, name, args);
|
||||
pipelinedCommands++;
|
||||
return this;
|
||||
@@ -126,9 +126,9 @@ public class Connection {
|
||||
return (String) protocol.read(inputStream);
|
||||
}
|
||||
|
||||
public int getIntegerReply() {
|
||||
public Integer getIntegerReply() {
|
||||
pipelinedCommands--;
|
||||
return ((Integer) protocol.read(inputStream)).intValue();
|
||||
return (Integer) protocol.read(inputStream);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -59,13 +59,13 @@ public class Jedis {
|
||||
client.quit();
|
||||
}
|
||||
|
||||
public int exists(String key) {
|
||||
public Integer exists(String key) {
|
||||
checkIsInMulti();
|
||||
client.exists(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int del(String... keys) {
|
||||
public Integer del(String... keys) {
|
||||
checkIsInMulti();
|
||||
client.del(keys);
|
||||
return client.getIntegerReply();
|
||||
@@ -101,31 +101,31 @@ public class Jedis {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int renamenx(String oldkey, String newkey) {
|
||||
public Integer renamenx(String oldkey, String newkey) {
|
||||
checkIsInMulti();
|
||||
client.renamenx(oldkey, newkey);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int dbSize() {
|
||||
public Integer dbSize() {
|
||||
checkIsInMulti();
|
||||
client.dbSize();
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int expire(String key, int seconds) {
|
||||
public Integer expire(String key, int seconds) {
|
||||
checkIsInMulti();
|
||||
client.expire(key, seconds);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int expireAt(String key, long unixTime) {
|
||||
public Integer expireAt(String key, long unixTime) {
|
||||
checkIsInMulti();
|
||||
client.expireAt(key, unixTime);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int ttl(String key) {
|
||||
public Integer ttl(String key) {
|
||||
checkIsInMulti();
|
||||
client.ttl(key);
|
||||
return client.getIntegerReply();
|
||||
@@ -137,7 +137,7 @@ public class Jedis {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int move(String key, int dbIndex) {
|
||||
public Integer move(String key, int dbIndex) {
|
||||
checkIsInMulti();
|
||||
client.move(key, dbIndex);
|
||||
return client.getIntegerReply();
|
||||
@@ -161,7 +161,7 @@ public class Jedis {
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public int setnx(String key, String value) {
|
||||
public Integer setnx(String key, String value) {
|
||||
checkIsInMulti();
|
||||
client.setnx(key, value);
|
||||
return client.getIntegerReply();
|
||||
@@ -179,37 +179,37 @@ public class Jedis {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int msetnx(String... keysvalues) {
|
||||
public Integer msetnx(String... keysvalues) {
|
||||
checkIsInMulti();
|
||||
client.msetnx(keysvalues);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int decrBy(String key, int integer) {
|
||||
public Integer decrBy(String key, int integer) {
|
||||
checkIsInMulti();
|
||||
client.decrBy(key, integer);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int decr(String key) {
|
||||
public Integer decr(String key) {
|
||||
checkIsInMulti();
|
||||
client.decr(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int incrBy(String key, int integer) {
|
||||
public Integer incrBy(String key, int integer) {
|
||||
checkIsInMulti();
|
||||
client.incrBy(key, integer);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int incr(String key) {
|
||||
public Integer incr(String key) {
|
||||
checkIsInMulti();
|
||||
client.incr(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int append(String key, String value) {
|
||||
public Integer append(String key, String value) {
|
||||
checkIsInMulti();
|
||||
client.append(key, value);
|
||||
return client.getIntegerReply();
|
||||
@@ -221,7 +221,7 @@ public class Jedis {
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int hset(String key, String field, String value) {
|
||||
public Integer hset(String key, String field, String value) {
|
||||
checkIsInMulti();
|
||||
client.hset(key, field, value);
|
||||
return client.getIntegerReply();
|
||||
@@ -233,7 +233,7 @@ public class Jedis {
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int hsetnx(String key, String field, String value) {
|
||||
public Integer hsetnx(String key, String field, String value) {
|
||||
checkIsInMulti();
|
||||
client.hsetnx(key, field, value);
|
||||
return client.getIntegerReply();
|
||||
@@ -251,25 +251,25 @@ public class Jedis {
|
||||
return client.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public int hincrBy(String key, String field, int value) {
|
||||
public Integer hincrBy(String key, String field, int value) {
|
||||
checkIsInMulti();
|
||||
client.hincrBy(key, field, value);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int hexists(String key, String field) {
|
||||
public Integer hexists(String key, String field) {
|
||||
checkIsInMulti();
|
||||
client.hexists(key, field);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int hdel(String key, String field) {
|
||||
public Integer hdel(String key, String field) {
|
||||
checkIsInMulti();
|
||||
client.hdel(key, field);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int hlen(String key) {
|
||||
public Integer hlen(String key) {
|
||||
checkIsInMulti();
|
||||
client.hlen(key);
|
||||
return client.getIntegerReply();
|
||||
@@ -300,19 +300,19 @@ public class Jedis {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public int rpush(String key, String string) {
|
||||
public Integer rpush(String key, String string) {
|
||||
checkIsInMulti();
|
||||
client.rpush(key, string);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int lpush(String key, String string) {
|
||||
public Integer lpush(String key, String string) {
|
||||
checkIsInMulti();
|
||||
client.lpush(key, string);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int llen(String key) {
|
||||
public Integer llen(String key) {
|
||||
checkIsInMulti();
|
||||
client.llen(key);
|
||||
return client.getIntegerReply();
|
||||
@@ -342,7 +342,7 @@ public class Jedis {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int lrem(String key, int count, String value) {
|
||||
public Integer lrem(String key, int count, String value) {
|
||||
checkIsInMulti();
|
||||
client.lrem(key, count, value);
|
||||
return client.getIntegerReply();
|
||||
@@ -366,7 +366,7 @@ public class Jedis {
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int sadd(String key, String member) {
|
||||
public Integer sadd(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.sadd(key, member);
|
||||
return client.getIntegerReply();
|
||||
@@ -379,7 +379,7 @@ public class Jedis {
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int srem(String key, String member) {
|
||||
public Integer srem(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.srem(key, member);
|
||||
return client.getIntegerReply();
|
||||
@@ -391,19 +391,19 @@ public class Jedis {
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int smove(String srckey, String dstkey, String member) {
|
||||
public Integer smove(String srckey, String dstkey, String member) {
|
||||
checkIsInMulti();
|
||||
client.smove(srckey, dstkey, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int scard(String key) {
|
||||
public Integer scard(String key) {
|
||||
checkIsInMulti();
|
||||
client.scard(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int sismember(String key, String member) {
|
||||
public Integer sismember(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.sismember(key, member);
|
||||
return client.getIntegerReply();
|
||||
@@ -416,7 +416,7 @@ public class Jedis {
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int sinterstore(String dstkey, String... keys) {
|
||||
public Integer sinterstore(String dstkey, String... keys) {
|
||||
checkIsInMulti();
|
||||
client.sinterstore(dstkey, keys);
|
||||
return client.getIntegerReply();
|
||||
@@ -429,7 +429,7 @@ public class Jedis {
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int sunionstore(String dstkey, String... keys) {
|
||||
public Integer sunionstore(String dstkey, String... keys) {
|
||||
checkIsInMulti();
|
||||
client.sunionstore(dstkey, keys);
|
||||
return client.getIntegerReply();
|
||||
@@ -442,7 +442,7 @@ public class Jedis {
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int sdiffstore(String dstkey, String... keys) {
|
||||
public Integer sdiffstore(String dstkey, String... keys) {
|
||||
checkIsInMulti();
|
||||
client.sdiffstore(dstkey, keys);
|
||||
return client.getIntegerReply();
|
||||
@@ -454,7 +454,7 @@ public class Jedis {
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public int zadd(String key, double score, String member) {
|
||||
public Integer zadd(String key, double score, String member) {
|
||||
checkIsInMulti();
|
||||
client.zadd(key, score, member);
|
||||
return client.getIntegerReply();
|
||||
@@ -467,26 +467,26 @@ public class Jedis {
|
||||
return new LinkedHashSet<String>(members);
|
||||
}
|
||||
|
||||
public int zrem(String key, String member) {
|
||||
public Integer zrem(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.zrem(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public double zincrby(String key, double score, String member) {
|
||||
public Double zincrby(String key, double score, String member) {
|
||||
checkIsInMulti();
|
||||
client.zincrby(key, score, member);
|
||||
String newscore = client.getBulkReply();
|
||||
return Double.valueOf(newscore).doubleValue();
|
||||
return Double.valueOf(newscore);
|
||||
}
|
||||
|
||||
public int zrank(String key, String member) {
|
||||
public Integer zrank(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.zrank(key, member);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zrevrank(String key, String member) {
|
||||
public Integer zrevrank(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.zrevrank(key, member);
|
||||
return client.getIntegerReply();
|
||||
@@ -513,17 +513,17 @@ public class Jedis {
|
||||
return set;
|
||||
}
|
||||
|
||||
public int zcard(String key) {
|
||||
public Integer zcard(String key) {
|
||||
checkIsInMulti();
|
||||
client.zcard(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public double zscore(String key, String member) {
|
||||
public Double zscore(String key, String member) {
|
||||
checkIsInMulti();
|
||||
client.zscore(key, member);
|
||||
String score = client.getBulkReply();
|
||||
return Double.valueOf(score).doubleValue();
|
||||
return (score != null ? new Double(score) : null);
|
||||
}
|
||||
|
||||
public Transaction multi() {
|
||||
@@ -597,13 +597,14 @@ public class Jedis {
|
||||
return multiBulkReply;
|
||||
}
|
||||
|
||||
public int sort(String key, SortingParams sortingParameters, String dstkey) {
|
||||
public Integer sort(String key, SortingParams sortingParameters,
|
||||
String dstkey) {
|
||||
checkIsInMulti();
|
||||
client.sort(key, sortingParameters, dstkey);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int sort(String key, String dstkey) {
|
||||
public Integer sort(String key, String dstkey) {
|
||||
checkIsInMulti();
|
||||
client.sort(key, dstkey);
|
||||
return client.getIntegerReply();
|
||||
@@ -643,7 +644,7 @@ public class Jedis {
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
public int publish(String channel, String message) {
|
||||
public Integer publish(String channel, String message) {
|
||||
client.publish(channel, message);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
@@ -654,7 +655,7 @@ public class Jedis {
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
public int zcount(String key, double min, double max) {
|
||||
public Integer zcount(String key, double min, double max) {
|
||||
checkIsInMulti();
|
||||
client.zcount(key, min, max);
|
||||
return client.getIntegerReply();
|
||||
@@ -694,43 +695,44 @@ public class Jedis {
|
||||
Set<Tuple> set = new LinkedHashSet<Tuple>();
|
||||
Iterator<String> iterator = membersWithScores.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
set.add(new Tuple(iterator.next(), Double.valueOf(iterator.next())
|
||||
.doubleValue()));
|
||||
set
|
||||
.add(new Tuple(iterator.next(), Double.valueOf(iterator
|
||||
.next())));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public int zremrangeByRank(String key, int start, int end) {
|
||||
public Integer zremrangeByRank(String key, int start, int end) {
|
||||
checkIsInMulti();
|
||||
client.zremrangeByRank(key, start, end);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zremrangeByScore(String key, double start, double end) {
|
||||
public Integer zremrangeByScore(String key, double start, double end) {
|
||||
checkIsInMulti();
|
||||
client.zremrangeByScore(key, start, end);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zunionstore(String dstkey, String... sets) {
|
||||
public Integer zunionstore(String dstkey, String... sets) {
|
||||
checkIsInMulti();
|
||||
client.zunionstore(dstkey, sets);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zunionstore(String dstkey, ZParams params, String... sets) {
|
||||
public Integer zunionstore(String dstkey, ZParams params, String... sets) {
|
||||
checkIsInMulti();
|
||||
client.zunionstore(dstkey, params, sets);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zinterstore(String dstkey, String... sets) {
|
||||
public Integer zinterstore(String dstkey, String... sets) {
|
||||
checkIsInMulti();
|
||||
client.zinterstore(dstkey, sets);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int zinterstore(String dstkey, ZParams params, String... sets) {
|
||||
public Integer zinterstore(String dstkey, ZParams params, String... sets) {
|
||||
checkIsInMulti();
|
||||
client.zinterstore(dstkey, params, sets);
|
||||
return client.getIntegerReply();
|
||||
@@ -751,7 +753,7 @@ public class Jedis {
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int lastsave() {
|
||||
public Integer lastsave() {
|
||||
client.lastsave();
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
@@ -801,7 +803,7 @@ public class Jedis {
|
||||
return client.isConnected();
|
||||
}
|
||||
|
||||
public int strlen(String key) {
|
||||
public Integer strlen(String key) {
|
||||
client.strlen(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
@@ -810,17 +812,17 @@ public class Jedis {
|
||||
client.sync();
|
||||
}
|
||||
|
||||
public int lpushx(String key, String string) {
|
||||
public Integer lpushx(String key, String string) {
|
||||
client.lpushx(key, string);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int persist(String key) {
|
||||
public Integer persist(String key) {
|
||||
client.persist(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public int rpushx(String key, String string) {
|
||||
public Integer rpushx(String key, String string) {
|
||||
client.rpushx(key, string);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.get(key);
|
||||
}
|
||||
|
||||
public int exists(String key) {
|
||||
public Integer exists(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
}
|
||||
@@ -38,17 +38,17 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.type(key);
|
||||
}
|
||||
|
||||
public int expire(String key, int seconds) {
|
||||
public Integer expire(String key, int seconds) {
|
||||
Jedis j = getShard(key);
|
||||
return j.expire(key, seconds);
|
||||
}
|
||||
|
||||
public int expireAt(String key, long unixTime) {
|
||||
public Integer expireAt(String key, long unixTime) {
|
||||
Jedis j = getShard(key);
|
||||
return j.expireAt(key, unixTime);
|
||||
}
|
||||
|
||||
public int ttl(String key) {
|
||||
public Integer ttl(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.ttl(key);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.getSet(key, value);
|
||||
}
|
||||
|
||||
public int setnx(String key, String value) {
|
||||
public Integer setnx(String key, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.setnx(key, value);
|
||||
}
|
||||
@@ -68,27 +68,27 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.setex(key, seconds, value);
|
||||
}
|
||||
|
||||
public int decrBy(String key, int integer) {
|
||||
public Integer decrBy(String key, int integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decrBy(key, integer);
|
||||
}
|
||||
|
||||
public int decr(String key) {
|
||||
public Integer decr(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decr(key);
|
||||
}
|
||||
|
||||
public int incrBy(String key, int integer) {
|
||||
public Integer incrBy(String key, int integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incrBy(key, integer);
|
||||
}
|
||||
|
||||
public int incr(String key) {
|
||||
public Integer incr(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.incr(key);
|
||||
}
|
||||
|
||||
public int append(String key, String value) {
|
||||
public Integer append(String key, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.append(key, value);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.substr(key, start, end);
|
||||
}
|
||||
|
||||
public int hset(String key, String field, String value) {
|
||||
public Integer hset(String key, String field, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hset(key, field, value);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.hget(key, field);
|
||||
}
|
||||
|
||||
public int hsetnx(String key, String field, String value) {
|
||||
public Integer hsetnx(String key, String field, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hsetnx(key, field, value);
|
||||
}
|
||||
@@ -123,22 +123,22 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.hmget(key, fields);
|
||||
}
|
||||
|
||||
public int hincrBy(String key, String field, int value) {
|
||||
public Integer hincrBy(String key, String field, int value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hincrBy(key, field, value);
|
||||
}
|
||||
|
||||
public int hexists(String key, String field) {
|
||||
public Integer hexists(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hexists(key, field);
|
||||
}
|
||||
|
||||
public int hdel(String key, String field) {
|
||||
public Integer hdel(String key, String field) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hdel(key, field);
|
||||
}
|
||||
|
||||
public int hlen(String key) {
|
||||
public Integer hlen(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.hlen(key);
|
||||
}
|
||||
@@ -158,17 +158,17 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.hgetAll(key);
|
||||
}
|
||||
|
||||
public int rpush(String key, String string) {
|
||||
public Integer rpush(String key, String string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpush(key, string);
|
||||
}
|
||||
|
||||
public int lpush(String key, String string) {
|
||||
public Integer lpush(String key, String string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lpush(key, string);
|
||||
}
|
||||
|
||||
public int llen(String key) {
|
||||
public Integer llen(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.llen(key);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.lset(key, index, value);
|
||||
}
|
||||
|
||||
public int lrem(String key, int count, String value) {
|
||||
public Integer lrem(String key, int count, String value) {
|
||||
Jedis j = getShard(key);
|
||||
return j.lrem(key, count, value);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.rpop(key);
|
||||
}
|
||||
|
||||
public int sadd(String key, String member) {
|
||||
public Integer sadd(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sadd(key, member);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.smembers(key);
|
||||
}
|
||||
|
||||
public int srem(String key, String member) {
|
||||
public Integer srem(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.srem(key, member);
|
||||
}
|
||||
@@ -228,12 +228,12 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.spop(key);
|
||||
}
|
||||
|
||||
public int scard(String key) {
|
||||
public Integer scard(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.scard(key);
|
||||
}
|
||||
|
||||
public int sismember(String key, String member) {
|
||||
public Integer sismember(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.sismember(key, member);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.srandmember(key);
|
||||
}
|
||||
|
||||
public int zadd(String key, double score, String member) {
|
||||
public Integer zadd(String key, double score, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zadd(key, score, member);
|
||||
}
|
||||
@@ -253,22 +253,22 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.zrange(key, start, end);
|
||||
}
|
||||
|
||||
public int zrem(String key, String member) {
|
||||
public Integer zrem(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrem(key, member);
|
||||
}
|
||||
|
||||
public double zincrby(String key, double score, String member) {
|
||||
public Double zincrby(String key, double score, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zincrby(key, score, member);
|
||||
}
|
||||
|
||||
public int zrank(String key, String member) {
|
||||
public Integer zrank(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrank(key, member);
|
||||
}
|
||||
|
||||
public int zrevrank(String key, String member) {
|
||||
public Integer zrevrank(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zrevrank(key, member);
|
||||
}
|
||||
@@ -288,12 +288,12 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.zrevrangeWithScores(key, start, end);
|
||||
}
|
||||
|
||||
public int zcard(String key) {
|
||||
public Integer zcard(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcard(key);
|
||||
}
|
||||
|
||||
public double zscore(String key, String member) {
|
||||
public Double zscore(String key, String member) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zscore(key, member);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.sort(key, sortingParameters);
|
||||
}
|
||||
|
||||
public int zcount(String key, double min, double max) {
|
||||
public Integer zcount(String key, double min, double max) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zcount(key, min, max);
|
||||
}
|
||||
@@ -335,12 +335,12 @@ public class ShardedJedis extends Sharded<Jedis> {
|
||||
return j.zrangeByScoreWithScores(key, min, max, offset, count);
|
||||
}
|
||||
|
||||
public int zremrangeByRank(String key, int start, int end) {
|
||||
public Integer zremrangeByRank(String key, int start, int end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByRank(key, start, end);
|
||||
}
|
||||
|
||||
public int zremrangeByScore(String key, double start, double end) {
|
||||
public Integer zremrangeByScore(String key, double start, double end) {
|
||||
Jedis j = getShard(key);
|
||||
return j.zremrangeByScore(key, start, end);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package redis.clients.jedis;
|
||||
|
||||
public class Tuple {
|
||||
private String element;
|
||||
private double score;
|
||||
private Double score;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@@ -35,7 +35,7 @@ public class Tuple {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Tuple(String element, double score) {
|
||||
public Tuple(String element, Double score) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.score = score;
|
||||
|
||||
@@ -197,27 +197,27 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void flushDB() {
|
||||
jedis.set("foo", "bar");
|
||||
assertEquals(1, jedis.dbSize());
|
||||
assertEquals(1, jedis.dbSize().intValue());
|
||||
jedis.set("bar", "foo");
|
||||
jedis.move("bar", 1);
|
||||
String status = jedis.flushDB();
|
||||
assertEquals("OK", status);
|
||||
assertEquals(0, jedis.dbSize());
|
||||
assertEquals(0, jedis.dbSize().intValue());
|
||||
jedis.select(1);
|
||||
assertEquals(1, jedis.dbSize());
|
||||
assertEquals(1, jedis.dbSize().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flushAll() {
|
||||
jedis.set("foo", "bar");
|
||||
assertEquals(1, jedis.dbSize());
|
||||
assertEquals(1, jedis.dbSize().intValue());
|
||||
jedis.set("bar", "foo");
|
||||
jedis.move("bar", 1);
|
||||
String status = jedis.flushAll();
|
||||
assertEquals("OK", status);
|
||||
assertEquals(0, jedis.dbSize());
|
||||
assertEquals(0, jedis.dbSize().intValue());
|
||||
jedis.select(1);
|
||||
assertEquals(0, jedis.dbSize());
|
||||
assertEquals(0, jedis.dbSize().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,7 +226,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
assertTrue(jedis.ttl("foo") > 0);
|
||||
int status = jedis.persist("foo");
|
||||
assertEquals(1, status);
|
||||
assertEquals(-1, jedis.ttl("foo"));
|
||||
assertEquals(-1, jedis.ttl("foo").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -84,9 +84,9 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
hash.put("car", "bar");
|
||||
jedis.hmset("foo", hash);
|
||||
|
||||
assertEquals(0, jedis.hexists("bar", "foo"));
|
||||
assertEquals(0, jedis.hexists("foo", "foo"));
|
||||
assertEquals(1, jedis.hexists("foo", "bar"));
|
||||
assertEquals(0, jedis.hexists("bar", "foo").intValue());
|
||||
assertEquals(0, jedis.hexists("foo", "foo").intValue());
|
||||
assertEquals(1, jedis.hexists("foo", "bar").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,9 +96,9 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
hash.put("car", "bar");
|
||||
jedis.hmset("foo", hash);
|
||||
|
||||
assertEquals(0, jedis.hdel("bar", "foo"));
|
||||
assertEquals(0, jedis.hdel("foo", "foo"));
|
||||
assertEquals(1, jedis.hdel("foo", "bar"));
|
||||
assertEquals(0, jedis.hdel("bar", "foo").intValue());
|
||||
assertEquals(0, jedis.hdel("foo", "foo").intValue());
|
||||
assertEquals(1, jedis.hdel("foo", "bar").intValue());
|
||||
assertEquals(null, jedis.hget("foo", "bar"));
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
hash.put("car", "bar");
|
||||
jedis.hmset("foo", hash);
|
||||
|
||||
assertEquals(0, jedis.hlen("bar"));
|
||||
assertEquals(2, jedis.hlen("foo"));
|
||||
assertEquals(0, jedis.hlen("bar").intValue());
|
||||
assertEquals(2, jedis.hlen("foo").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -27,10 +27,10 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
@Test
|
||||
public void llen() {
|
||||
assertEquals(0, jedis.llen("foo"));
|
||||
assertEquals(0, jedis.llen("foo").intValue());
|
||||
jedis.lpush("foo", "bar");
|
||||
jedis.lpush("foo", "car");
|
||||
assertEquals(2, jedis.llen("foo"));
|
||||
assertEquals(2, jedis.llen("foo").intValue());
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
@@ -80,7 +80,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
expected.add("2");
|
||||
|
||||
assertEquals("OK", status);
|
||||
assertEquals(2, jedis.llen("foo"));
|
||||
assertEquals(2, jedis.llen("foo").intValue());
|
||||
assertEquals(expected, jedis.lrange("foo", 0, 100));
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
assertEquals(2, count);
|
||||
assertEquals(expected, jedis.lrange("foo", 0, 1000));
|
||||
assertEquals(0, jedis.lrem("bar", 100, "foo"));
|
||||
assertEquals(0, jedis.lrem("bar", 100, "foo").intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -175,11 +175,14 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
jedis.zadd("foo", 2d, "a");
|
||||
|
||||
double score = jedis.zscore("foo", "b");
|
||||
Double score = jedis.zscore("foo", "b");
|
||||
assertEquals(10d, score);
|
||||
|
||||
score = jedis.zscore("foo", "c");
|
||||
assertEquals(0.1d, score);
|
||||
|
||||
score = jedis.zscore("foo", "s");
|
||||
assertNull(score);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -301,8 +304,8 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(2, result);
|
||||
|
||||
Set<Tuple> expected = new LinkedHashSet<Tuple>();
|
||||
expected.add(new Tuple("b", 4));
|
||||
expected.add(new Tuple("a", 3));
|
||||
expected.add(new Tuple("b", new Double(4)));
|
||||
expected.add(new Tuple("a", new Double(3)));
|
||||
|
||||
assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
|
||||
}
|
||||
@@ -322,8 +325,8 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(2, result);
|
||||
|
||||
Set<Tuple> expected = new LinkedHashSet<Tuple>();
|
||||
expected.add(new Tuple("b", 8));
|
||||
expected.add(new Tuple("a", 6));
|
||||
expected.add(new Tuple("b", new Double(8)));
|
||||
expected.add(new Tuple("a", new Double(6)));
|
||||
|
||||
assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
|
||||
}
|
||||
@@ -339,7 +342,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(1, result);
|
||||
|
||||
Set<Tuple> expected = new LinkedHashSet<Tuple>();
|
||||
expected.add(new Tuple("a", 3));
|
||||
expected.add(new Tuple("a", new Double(3)));
|
||||
|
||||
assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
|
||||
}
|
||||
@@ -358,7 +361,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(1, result);
|
||||
|
||||
Set<Tuple> expected = new LinkedHashSet<Tuple>();
|
||||
expected.add(new Tuple("a", 6));
|
||||
expected.add(new Tuple("a", new Double(6)));
|
||||
|
||||
assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
|
||||
}
|
||||
|
||||
@@ -173,6 +173,6 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void strlen() {
|
||||
jedis.set("s", "This is a string");
|
||||
assertEquals("This is a string".length(), jedis.strlen("s"));
|
||||
assertEquals("This is a string".length(), jedis.strlen("s").intValue());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user