Refactores primitive types in the API. Now int -> Integer and double -> Double.

This is to support Redis null values
This commit is contained in:
Jonathan Leibiusky
2010-09-15 14:41:35 -03:00
parent a9d8dfe3d7
commit ed20894c95
9 changed files with 140 additions and 135 deletions

View File

@@ -1,15 +1,15 @@
package redis.clients.jedis; package redis.clients.jedis;
import redis.clients.util.RedisInputStream; import java.io.IOException;
import redis.clients.util.RedisOutputStream;
import java.io.*;
import java.net.Socket; import java.net.Socket;
import java.net.SocketException; import java.net.SocketException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import redis.clients.util.RedisInputStream;
import redis.clients.util.RedisOutputStream;
public class Connection { public class Connection {
private String host; private String host;
private int port = Protocol.DEFAULT_PORT; private int port = Protocol.DEFAULT_PORT;
@@ -126,9 +126,9 @@ public class Connection {
return (String) protocol.read(inputStream); return (String) protocol.read(inputStream);
} }
public int getIntegerReply() { public Integer getIntegerReply() {
pipelinedCommands--; pipelinedCommands--;
return ((Integer) protocol.read(inputStream)).intValue(); return (Integer) protocol.read(inputStream);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@@ -59,13 +59,13 @@ public class Jedis {
client.quit(); client.quit();
} }
public int exists(String key) { public Integer exists(String key) {
checkIsInMulti(); checkIsInMulti();
client.exists(key); client.exists(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int del(String... keys) { public Integer del(String... keys) {
checkIsInMulti(); checkIsInMulti();
client.del(keys); client.del(keys);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -101,31 +101,31 @@ public class Jedis {
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int renamenx(String oldkey, String newkey) { public Integer renamenx(String oldkey, String newkey) {
checkIsInMulti(); checkIsInMulti();
client.renamenx(oldkey, newkey); client.renamenx(oldkey, newkey);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int dbSize() { public Integer dbSize() {
checkIsInMulti(); checkIsInMulti();
client.dbSize(); client.dbSize();
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int expire(String key, int seconds) { public Integer expire(String key, int seconds) {
checkIsInMulti(); checkIsInMulti();
client.expire(key, seconds); client.expire(key, seconds);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int expireAt(String key, long unixTime) { public Integer expireAt(String key, long unixTime) {
checkIsInMulti(); checkIsInMulti();
client.expireAt(key, unixTime); client.expireAt(key, unixTime);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int ttl(String key) { public Integer ttl(String key) {
checkIsInMulti(); checkIsInMulti();
client.ttl(key); client.ttl(key);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -137,7 +137,7 @@ public class Jedis {
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int move(String key, int dbIndex) { public Integer move(String key, int dbIndex) {
checkIsInMulti(); checkIsInMulti();
client.move(key, dbIndex); client.move(key, dbIndex);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -161,7 +161,7 @@ public class Jedis {
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public int setnx(String key, String value) { public Integer setnx(String key, String value) {
checkIsInMulti(); checkIsInMulti();
client.setnx(key, value); client.setnx(key, value);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -179,37 +179,37 @@ public class Jedis {
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int msetnx(String... keysvalues) { public Integer msetnx(String... keysvalues) {
checkIsInMulti(); checkIsInMulti();
client.msetnx(keysvalues); client.msetnx(keysvalues);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int decrBy(String key, int integer) { public Integer decrBy(String key, int integer) {
checkIsInMulti(); checkIsInMulti();
client.decrBy(key, integer); client.decrBy(key, integer);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int decr(String key) { public Integer decr(String key) {
checkIsInMulti(); checkIsInMulti();
client.decr(key); client.decr(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int incrBy(String key, int integer) { public Integer incrBy(String key, int integer) {
checkIsInMulti(); checkIsInMulti();
client.incrBy(key, integer); client.incrBy(key, integer);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int incr(String key) { public Integer incr(String key) {
checkIsInMulti(); checkIsInMulti();
client.incr(key); client.incr(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int append(String key, String value) { public Integer append(String key, String value) {
checkIsInMulti(); checkIsInMulti();
client.append(key, value); client.append(key, value);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -221,7 +221,7 @@ public class Jedis {
return client.getBulkReply(); return client.getBulkReply();
} }
public int hset(String key, String field, String value) { public Integer hset(String key, String field, String value) {
checkIsInMulti(); checkIsInMulti();
client.hset(key, field, value); client.hset(key, field, value);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -233,7 +233,7 @@ public class Jedis {
return client.getBulkReply(); return client.getBulkReply();
} }
public int hsetnx(String key, String field, String value) { public Integer hsetnx(String key, String field, String value) {
checkIsInMulti(); checkIsInMulti();
client.hsetnx(key, field, value); client.hsetnx(key, field, value);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -251,25 +251,25 @@ public class Jedis {
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public int hincrBy(String key, String field, int value) { public Integer hincrBy(String key, String field, int value) {
checkIsInMulti(); checkIsInMulti();
client.hincrBy(key, field, value); client.hincrBy(key, field, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int hexists(String key, String field) { public Integer hexists(String key, String field) {
checkIsInMulti(); checkIsInMulti();
client.hexists(key, field); client.hexists(key, field);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int hdel(String key, String field) { public Integer hdel(String key, String field) {
checkIsInMulti(); checkIsInMulti();
client.hdel(key, field); client.hdel(key, field);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int hlen(String key) { public Integer hlen(String key) {
checkIsInMulti(); checkIsInMulti();
client.hlen(key); client.hlen(key);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -300,19 +300,19 @@ public class Jedis {
return hash; return hash;
} }
public int rpush(String key, String string) { public Integer rpush(String key, String string) {
checkIsInMulti(); checkIsInMulti();
client.rpush(key, string); client.rpush(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int lpush(String key, String string) { public Integer lpush(String key, String string) {
checkIsInMulti(); checkIsInMulti();
client.lpush(key, string); client.lpush(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int llen(String key) { public Integer llen(String key) {
checkIsInMulti(); checkIsInMulti();
client.llen(key); client.llen(key);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -342,7 +342,7 @@ public class Jedis {
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int lrem(String key, int count, String value) { public Integer lrem(String key, int count, String value) {
checkIsInMulti(); checkIsInMulti();
client.lrem(key, count, value); client.lrem(key, count, value);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -366,7 +366,7 @@ public class Jedis {
return client.getBulkReply(); return client.getBulkReply();
} }
public int sadd(String key, String member) { public Integer sadd(String key, String member) {
checkIsInMulti(); checkIsInMulti();
client.sadd(key, member); client.sadd(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -379,7 +379,7 @@ public class Jedis {
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int srem(String key, String member) { public Integer srem(String key, String member) {
checkIsInMulti(); checkIsInMulti();
client.srem(key, member); client.srem(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -391,19 +391,19 @@ public class Jedis {
return client.getBulkReply(); return client.getBulkReply();
} }
public int smove(String srckey, String dstkey, String member) { public Integer smove(String srckey, String dstkey, String member) {
checkIsInMulti(); checkIsInMulti();
client.smove(srckey, dstkey, member); client.smove(srckey, dstkey, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int scard(String key) { public Integer scard(String key) {
checkIsInMulti(); checkIsInMulti();
client.scard(key); client.scard(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int sismember(String key, String member) { public Integer sismember(String key, String member) {
checkIsInMulti(); checkIsInMulti();
client.sismember(key, member); client.sismember(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -416,7 +416,7 @@ public class Jedis {
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int sinterstore(String dstkey, String... keys) { public Integer sinterstore(String dstkey, String... keys) {
checkIsInMulti(); checkIsInMulti();
client.sinterstore(dstkey, keys); client.sinterstore(dstkey, keys);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -429,7 +429,7 @@ public class Jedis {
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int sunionstore(String dstkey, String... keys) { public Integer sunionstore(String dstkey, String... keys) {
checkIsInMulti(); checkIsInMulti();
client.sunionstore(dstkey, keys); client.sunionstore(dstkey, keys);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -442,7 +442,7 @@ public class Jedis {
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int sdiffstore(String dstkey, String... keys) { public Integer sdiffstore(String dstkey, String... keys) {
checkIsInMulti(); checkIsInMulti();
client.sdiffstore(dstkey, keys); client.sdiffstore(dstkey, keys);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -454,7 +454,7 @@ public class Jedis {
return client.getBulkReply(); return client.getBulkReply();
} }
public int zadd(String key, double score, String member) { public Integer zadd(String key, double score, String member) {
checkIsInMulti(); checkIsInMulti();
client.zadd(key, score, member); client.zadd(key, score, member);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -467,26 +467,26 @@ public class Jedis {
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int zrem(String key, String member) { public Integer zrem(String key, String member) {
checkIsInMulti(); checkIsInMulti();
client.zrem(key, member); client.zrem(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public double zincrby(String key, double score, String member) { public Double zincrby(String key, double score, String member) {
checkIsInMulti(); checkIsInMulti();
client.zincrby(key, score, member); client.zincrby(key, score, member);
String newscore = client.getBulkReply(); 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(); checkIsInMulti();
client.zrank(key, member); client.zrank(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zrevrank(String key, String member) { public Integer zrevrank(String key, String member) {
checkIsInMulti(); checkIsInMulti();
client.zrevrank(key, member); client.zrevrank(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -513,17 +513,17 @@ public class Jedis {
return set; return set;
} }
public int zcard(String key) { public Integer zcard(String key) {
checkIsInMulti(); checkIsInMulti();
client.zcard(key); client.zcard(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public double zscore(String key, String member) { public Double zscore(String key, String member) {
checkIsInMulti(); checkIsInMulti();
client.zscore(key, member); client.zscore(key, member);
String score = client.getBulkReply(); String score = client.getBulkReply();
return Double.valueOf(score).doubleValue(); return (score != null ? new Double(score) : null);
} }
public Transaction multi() { public Transaction multi() {
@@ -597,13 +597,14 @@ public class Jedis {
return multiBulkReply; return multiBulkReply;
} }
public int sort(String key, SortingParams sortingParameters, String dstkey) { public Integer sort(String key, SortingParams sortingParameters,
String dstkey) {
checkIsInMulti(); checkIsInMulti();
client.sort(key, sortingParameters, dstkey); client.sort(key, sortingParameters, dstkey);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int sort(String key, String dstkey) { public Integer sort(String key, String dstkey) {
checkIsInMulti(); checkIsInMulti();
client.sort(key, dstkey); client.sort(key, dstkey);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -643,7 +644,7 @@ public class Jedis {
client.rollbackTimeout(); client.rollbackTimeout();
} }
public int publish(String channel, String message) { public Integer publish(String channel, String message) {
client.publish(channel, message); client.publish(channel, message);
return client.getIntegerReply(); return client.getIntegerReply();
} }
@@ -654,7 +655,7 @@ public class Jedis {
client.rollbackTimeout(); client.rollbackTimeout();
} }
public int zcount(String key, double min, double max) { public Integer zcount(String key, double min, double max) {
checkIsInMulti(); checkIsInMulti();
client.zcount(key, min, max); client.zcount(key, min, max);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -694,43 +695,44 @@ public class Jedis {
Set<Tuple> set = new LinkedHashSet<Tuple>(); Set<Tuple> set = new LinkedHashSet<Tuple>();
Iterator<String> iterator = membersWithScores.iterator(); Iterator<String> iterator = membersWithScores.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
set.add(new Tuple(iterator.next(), Double.valueOf(iterator.next()) set
.doubleValue())); .add(new Tuple(iterator.next(), Double.valueOf(iterator
.next())));
} }
return set; return set;
} }
public int zremrangeByRank(String key, int start, int end) { public Integer zremrangeByRank(String key, int start, int end) {
checkIsInMulti(); checkIsInMulti();
client.zremrangeByRank(key, start, end); client.zremrangeByRank(key, start, end);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zremrangeByScore(String key, double start, double end) { public Integer zremrangeByScore(String key, double start, double end) {
checkIsInMulti(); checkIsInMulti();
client.zremrangeByScore(key, start, end); client.zremrangeByScore(key, start, end);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zunionstore(String dstkey, String... sets) { public Integer zunionstore(String dstkey, String... sets) {
checkIsInMulti(); checkIsInMulti();
client.zunionstore(dstkey, sets); client.zunionstore(dstkey, sets);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zunionstore(String dstkey, ZParams params, String... sets) { public Integer zunionstore(String dstkey, ZParams params, String... sets) {
checkIsInMulti(); checkIsInMulti();
client.zunionstore(dstkey, params, sets); client.zunionstore(dstkey, params, sets);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zinterstore(String dstkey, String... sets) { public Integer zinterstore(String dstkey, String... sets) {
checkIsInMulti(); checkIsInMulti();
client.zinterstore(dstkey, sets); client.zinterstore(dstkey, sets);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zinterstore(String dstkey, ZParams params, String... sets) { public Integer zinterstore(String dstkey, ZParams params, String... sets) {
checkIsInMulti(); checkIsInMulti();
client.zinterstore(dstkey, params, sets); client.zinterstore(dstkey, params, sets);
return client.getIntegerReply(); return client.getIntegerReply();
@@ -751,7 +753,7 @@ public class Jedis {
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int lastsave() { public Integer lastsave() {
client.lastsave(); client.lastsave();
return client.getIntegerReply(); return client.getIntegerReply();
} }
@@ -801,7 +803,7 @@ public class Jedis {
return client.isConnected(); return client.isConnected();
} }
public int strlen(String key) { public Integer strlen(String key) {
client.strlen(key); client.strlen(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
@@ -810,17 +812,17 @@ public class Jedis {
client.sync(); client.sync();
} }
public int lpushx(String key, String string) { public Integer lpushx(String key, String string) {
client.lpushx(key, string); client.lpushx(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int persist(String key) { public Integer persist(String key) {
client.persist(key); client.persist(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int rpushx(String key, String string) { public Integer rpushx(String key, String string) {
client.rpushx(key, string); client.rpushx(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }

View File

@@ -28,7 +28,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.get(key); return j.get(key);
} }
public int exists(String key) { public Integer exists(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.exists(key); return j.exists(key);
} }
@@ -38,17 +38,17 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.type(key); return j.type(key);
} }
public int expire(String key, int seconds) { public Integer expire(String key, int seconds) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.expire(key, seconds); return j.expire(key, seconds);
} }
public int expireAt(String key, long unixTime) { public Integer expireAt(String key, long unixTime) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.expireAt(key, unixTime); return j.expireAt(key, unixTime);
} }
public int ttl(String key) { public Integer ttl(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.ttl(key); return j.ttl(key);
} }
@@ -58,7 +58,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.getSet(key, value); return j.getSet(key, value);
} }
public int setnx(String key, String value) { public Integer setnx(String key, String value) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.setnx(key, value); return j.setnx(key, value);
} }
@@ -68,27 +68,27 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.setex(key, seconds, value); return j.setex(key, seconds, value);
} }
public int decrBy(String key, int integer) { public Integer decrBy(String key, int integer) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.decrBy(key, integer); return j.decrBy(key, integer);
} }
public int decr(String key) { public Integer decr(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.decr(key); return j.decr(key);
} }
public int incrBy(String key, int integer) { public Integer incrBy(String key, int integer) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.incrBy(key, integer); return j.incrBy(key, integer);
} }
public int incr(String key) { public Integer incr(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.incr(key); return j.incr(key);
} }
public int append(String key, String value) { public Integer append(String key, String value) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.append(key, value); return j.append(key, value);
} }
@@ -98,7 +98,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.substr(key, start, end); 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); Jedis j = getShard(key);
return j.hset(key, field, value); return j.hset(key, field, value);
} }
@@ -108,7 +108,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.hget(key, field); 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); Jedis j = getShard(key);
return j.hsetnx(key, field, value); return j.hsetnx(key, field, value);
} }
@@ -123,22 +123,22 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.hmget(key, fields); 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); Jedis j = getShard(key);
return j.hincrBy(key, field, value); return j.hincrBy(key, field, value);
} }
public int hexists(String key, String field) { public Integer hexists(String key, String field) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.hexists(key, field); return j.hexists(key, field);
} }
public int hdel(String key, String field) { public Integer hdel(String key, String field) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.hdel(key, field); return j.hdel(key, field);
} }
public int hlen(String key) { public Integer hlen(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.hlen(key); return j.hlen(key);
} }
@@ -158,17 +158,17 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.hgetAll(key); return j.hgetAll(key);
} }
public int rpush(String key, String string) { public Integer rpush(String key, String string) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.rpush(key, string); return j.rpush(key, string);
} }
public int lpush(String key, String string) { public Integer lpush(String key, String string) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.lpush(key, string); return j.lpush(key, string);
} }
public int llen(String key) { public Integer llen(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.llen(key); return j.llen(key);
} }
@@ -193,7 +193,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.lset(key, index, value); 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); Jedis j = getShard(key);
return j.lrem(key, count, value); return j.lrem(key, count, value);
} }
@@ -208,7 +208,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.rpop(key); return j.rpop(key);
} }
public int sadd(String key, String member) { public Integer sadd(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.sadd(key, member); return j.sadd(key, member);
} }
@@ -218,7 +218,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.smembers(key); return j.smembers(key);
} }
public int srem(String key, String member) { public Integer srem(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.srem(key, member); return j.srem(key, member);
} }
@@ -228,12 +228,12 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.spop(key); return j.spop(key);
} }
public int scard(String key) { public Integer scard(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.scard(key); return j.scard(key);
} }
public int sismember(String key, String member) { public Integer sismember(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.sismember(key, member); return j.sismember(key, member);
} }
@@ -243,7 +243,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.srandmember(key); 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); Jedis j = getShard(key);
return j.zadd(key, score, member); return j.zadd(key, score, member);
} }
@@ -253,22 +253,22 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.zrange(key, start, end); return j.zrange(key, start, end);
} }
public int zrem(String key, String member) { public Integer zrem(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zrem(key, member); 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); Jedis j = getShard(key);
return j.zincrby(key, score, member); return j.zincrby(key, score, member);
} }
public int zrank(String key, String member) { public Integer zrank(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zrank(key, member); return j.zrank(key, member);
} }
public int zrevrank(String key, String member) { public Integer zrevrank(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zrevrank(key, member); return j.zrevrank(key, member);
} }
@@ -288,12 +288,12 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.zrevrangeWithScores(key, start, end); return j.zrevrangeWithScores(key, start, end);
} }
public int zcard(String key) { public Integer zcard(String key) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zcard(key); return j.zcard(key);
} }
public double zscore(String key, String member) { public Double zscore(String key, String member) {
Jedis j = getShard(key); Jedis j = getShard(key);
return j.zscore(key, member); return j.zscore(key, member);
} }
@@ -308,7 +308,7 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.sort(key, sortingParameters); 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); Jedis j = getShard(key);
return j.zcount(key, min, max); return j.zcount(key, min, max);
} }
@@ -335,12 +335,12 @@ public class ShardedJedis extends Sharded<Jedis> {
return j.zrangeByScoreWithScores(key, min, max, offset, count); 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); Jedis j = getShard(key);
return j.zremrangeByRank(key, start, end); 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); Jedis j = getShard(key);
return j.zremrangeByScore(key, start, end); return j.zremrangeByScore(key, start, end);
} }

View File

@@ -2,7 +2,7 @@ package redis.clients.jedis;
public class Tuple { public class Tuple {
private String element; private String element;
private double score; private Double score;
@Override @Override
public int hashCode() { public int hashCode() {
@@ -35,7 +35,7 @@ public class Tuple {
return true; return true;
} }
public Tuple(String element, double score) { public Tuple(String element, Double score) {
super(); super();
this.element = element; this.element = element;
this.score = score; this.score = score;

View File

@@ -197,27 +197,27 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
@Test @Test
public void flushDB() { public void flushDB() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
assertEquals(1, jedis.dbSize()); assertEquals(1, jedis.dbSize().intValue());
jedis.set("bar", "foo"); jedis.set("bar", "foo");
jedis.move("bar", 1); jedis.move("bar", 1);
String status = jedis.flushDB(); String status = jedis.flushDB();
assertEquals("OK", status); assertEquals("OK", status);
assertEquals(0, jedis.dbSize()); assertEquals(0, jedis.dbSize().intValue());
jedis.select(1); jedis.select(1);
assertEquals(1, jedis.dbSize()); assertEquals(1, jedis.dbSize().intValue());
} }
@Test @Test
public void flushAll() { public void flushAll() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
assertEquals(1, jedis.dbSize()); assertEquals(1, jedis.dbSize().intValue());
jedis.set("bar", "foo"); jedis.set("bar", "foo");
jedis.move("bar", 1); jedis.move("bar", 1);
String status = jedis.flushAll(); String status = jedis.flushAll();
assertEquals("OK", status); assertEquals("OK", status);
assertEquals(0, jedis.dbSize()); assertEquals(0, jedis.dbSize().intValue());
jedis.select(1); jedis.select(1);
assertEquals(0, jedis.dbSize()); assertEquals(0, jedis.dbSize().intValue());
} }
@Test @Test
@@ -226,7 +226,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
assertTrue(jedis.ttl("foo") > 0); assertTrue(jedis.ttl("foo") > 0);
int status = jedis.persist("foo"); int status = jedis.persist("foo");
assertEquals(1, status); assertEquals(1, status);
assertEquals(-1, jedis.ttl("foo")); assertEquals(-1, jedis.ttl("foo").intValue());
} }
@Test @Test

View File

@@ -84,9 +84,9 @@ public class HashesCommandsTest extends JedisCommandTestBase {
hash.put("car", "bar"); hash.put("car", "bar");
jedis.hmset("foo", hash); jedis.hmset("foo", hash);
assertEquals(0, jedis.hexists("bar", "foo")); assertEquals(0, jedis.hexists("bar", "foo").intValue());
assertEquals(0, jedis.hexists("foo", "foo")); assertEquals(0, jedis.hexists("foo", "foo").intValue());
assertEquals(1, jedis.hexists("foo", "bar")); assertEquals(1, jedis.hexists("foo", "bar").intValue());
} }
@Test @Test
@@ -96,9 +96,9 @@ public class HashesCommandsTest extends JedisCommandTestBase {
hash.put("car", "bar"); hash.put("car", "bar");
jedis.hmset("foo", hash); jedis.hmset("foo", hash);
assertEquals(0, jedis.hdel("bar", "foo")); assertEquals(0, jedis.hdel("bar", "foo").intValue());
assertEquals(0, jedis.hdel("foo", "foo")); assertEquals(0, jedis.hdel("foo", "foo").intValue());
assertEquals(1, jedis.hdel("foo", "bar")); assertEquals(1, jedis.hdel("foo", "bar").intValue());
assertEquals(null, jedis.hget("foo", "bar")); assertEquals(null, jedis.hget("foo", "bar"));
} }
@@ -109,8 +109,8 @@ public class HashesCommandsTest extends JedisCommandTestBase {
hash.put("car", "bar"); hash.put("car", "bar");
jedis.hmset("foo", hash); jedis.hmset("foo", hash);
assertEquals(0, jedis.hlen("bar")); assertEquals(0, jedis.hlen("bar").intValue());
assertEquals(2, jedis.hlen("foo")); assertEquals(2, jedis.hlen("foo").intValue());
} }
@Test @Test

View File

@@ -27,10 +27,10 @@ public class ListCommandsTest extends JedisCommandTestBase {
@Test @Test
public void llen() { public void llen() {
assertEquals(0, jedis.llen("foo")); assertEquals(0, jedis.llen("foo").intValue());
jedis.lpush("foo", "bar"); jedis.lpush("foo", "bar");
jedis.lpush("foo", "car"); jedis.lpush("foo", "car");
assertEquals(2, jedis.llen("foo")); assertEquals(2, jedis.llen("foo").intValue());
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
@@ -80,7 +80,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
expected.add("2"); expected.add("2");
assertEquals("OK", status); assertEquals("OK", status);
assertEquals(2, jedis.llen("foo")); assertEquals(2, jedis.llen("foo").intValue());
assertEquals(expected, jedis.lrange("foo", 0, 100)); assertEquals(expected, jedis.lrange("foo", 0, 100));
} }
@@ -132,7 +132,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
assertEquals(2, count); assertEquals(2, count);
assertEquals(expected, jedis.lrange("foo", 0, 1000)); assertEquals(expected, jedis.lrange("foo", 0, 1000));
assertEquals(0, jedis.lrem("bar", 100, "foo")); assertEquals(0, jedis.lrem("bar", 100, "foo").intValue());
} }
@Test @Test

View File

@@ -175,11 +175,14 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");
jedis.zadd("foo", 2d, "a"); jedis.zadd("foo", 2d, "a");
double score = jedis.zscore("foo", "b"); Double score = jedis.zscore("foo", "b");
assertEquals(10d, score); assertEquals(10d, score);
score = jedis.zscore("foo", "c"); score = jedis.zscore("foo", "c");
assertEquals(0.1d, score); assertEquals(0.1d, score);
score = jedis.zscore("foo", "s");
assertNull(score);
} }
@Test @Test
@@ -301,8 +304,8 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(2, result); assertEquals(2, result);
Set<Tuple> expected = new LinkedHashSet<Tuple>(); Set<Tuple> expected = new LinkedHashSet<Tuple>();
expected.add(new Tuple("b", 4)); expected.add(new Tuple("b", new Double(4)));
expected.add(new Tuple("a", 3)); expected.add(new Tuple("a", new Double(3)));
assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100)); assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
} }
@@ -322,8 +325,8 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(2, result); assertEquals(2, result);
Set<Tuple> expected = new LinkedHashSet<Tuple>(); Set<Tuple> expected = new LinkedHashSet<Tuple>();
expected.add(new Tuple("b", 8)); expected.add(new Tuple("b", new Double(8)));
expected.add(new Tuple("a", 6)); expected.add(new Tuple("a", new Double(6)));
assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100)); assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
} }
@@ -339,7 +342,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(1, result); assertEquals(1, result);
Set<Tuple> expected = new LinkedHashSet<Tuple>(); 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)); assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
} }
@@ -358,7 +361,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
assertEquals(1, result); assertEquals(1, result);
Set<Tuple> expected = new LinkedHashSet<Tuple>(); 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)); assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));
} }

View File

@@ -173,6 +173,6 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
@Test @Test
public void strlen() { public void strlen() {
jedis.set("s", "This is a string"); 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());
} }
} }