Add Redis 2.6 incrBy/hincrBy float ops to Connections

DATAREDIS-181
This commit is contained in:
Jennifer Hickey
2013-06-17 15:06:55 -07:00
parent 45627760aa
commit ced5a755e9
13 changed files with 153 additions and 3 deletions

View File

@@ -188,6 +188,10 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
return delegate.hIncrBy(key, field, delta);
}
public Double hIncrBy(byte[] key, byte[] field, double delta) {
return delegate.hIncrBy(key, field, delta);
}
public Set<byte[]> hKeys(byte[] key) {
return delegate.hKeys(key);
}
@@ -224,6 +228,10 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
return delegate.incrBy(key, value);
}
public Double incrBy(byte[] key, double value) {
return delegate.incrBy(key, value);
}
public Properties info() {
return delegate.info();
}
@@ -772,6 +780,9 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
return delegate.hIncrBy(serialize(key), serialize(field), delta);
}
public Double hIncrBy(String key, String field, double delta) {
return delegate.hIncrBy(serialize(key), serialize(field), delta);
}
public Set<String> hKeys(String key) {
return deserialize(delegate.hKeys(serialize(key)));
@@ -816,7 +827,10 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
return delegate.incrBy(serialize(key), value);
}
public Double incrBy(String key, double value) {
return delegate.incrBy(serialize(key), value);
}
public Collection<String> keys(String pattern) {
return deserialize(delegate.keys(serialize(pattern)));
}

View File

@@ -39,6 +39,8 @@ public interface RedisHashCommands {
Long hIncrBy(byte[] key, byte[] field, long delta);
Double hIncrBy(byte[] key, byte[] field, double delta);
Boolean hExists(byte[] key, byte[] field);
Boolean hDel(byte[] key, byte[] field);

View File

@@ -50,6 +50,8 @@ public interface RedisStringCommands {
Long incrBy(byte[] key, long value);
Double incrBy(byte[] key, double value);
Long decr(byte[] key);
Long decrBy(byte[] key, long value);

View File

@@ -101,6 +101,8 @@ public interface StringRedisConnection extends RedisConnection {
Long incrBy(String key, long value);
Double incrBy(String key, double value);
Long decr(String key);
Long decrBy(String key, long value);
@@ -241,6 +243,8 @@ public interface StringRedisConnection extends RedisConnection {
Long hIncrBy(String key, String field, long delta);
Double hIncrBy(String key, String field, double delta);
Boolean hExists(String key, String field);
Boolean hDel(String key, String field);

View File

@@ -1119,6 +1119,9 @@ public class JedisConnection implements RedisConnection {
}
}
public Double incrBy(byte[] key, double value) {
throw new UnsupportedOperationException();
}
public Boolean getBit(byte[] key, long offset) {
try {
@@ -2306,6 +2309,9 @@ public class JedisConnection implements RedisConnection {
}
}
public Double hIncrBy(byte[] key, byte[] field, double delta) {
throw new UnsupportedOperationException();
}
public Set<byte[]> hKeys(byte[] key) {
try {

View File

@@ -582,6 +582,11 @@ public class JredisConnection implements RedisConnection {
}
public Double incrBy(byte[] key, double value) {
throw new UnsupportedOperationException();
}
public Boolean getBit(byte[] key, long offset) {
try {
return jredis.getbit(key, (int)offset);
@@ -1139,6 +1144,9 @@ public class JredisConnection implements RedisConnection {
throw new UnsupportedOperationException();
}
public Double hIncrBy(byte[] key, byte[] field, double delta) {
throw new UnsupportedOperationException();
}
public Set<byte[]> hKeys(byte[] key) {
try {

View File

@@ -949,6 +949,18 @@ public class LettuceConnection implements RedisConnection {
}
}
public Double incrBy(byte[] key, double value) {
try {
if (isPipelined()) {
pipeline(getAsyncConnection().incrbyfloat(key, value));
return null;
}
return getConnection().incrbyfloat(key, value);
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
}
public Boolean getBit(byte[] key, long offset) {
try {
if (isPipelined()) {
@@ -1874,6 +1886,18 @@ public class LettuceConnection implements RedisConnection {
}
}
public Double hIncrBy(byte[] key, byte[] field, double delta) {
try {
if (isPipelined()) {
pipeline(getAsyncConnection().hincrbyfloat(key, field, delta));
return null;
}
return getConnection().hincrbyfloat(key, field, delta);
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
}
public Set<byte[]> hKeys(byte[] key) {
try {
if (isPipelined()) {

View File

@@ -904,6 +904,19 @@ public class SrpConnection implements RedisConnection {
}
public Double incrBy(byte[] key, double value) {
try {
if (isPipelined()) {
pipeline(pipeline.incrbyfloat(key, value));
return null;
}
return SrpUtils.toDouble(client.incrbyfloat(key, value).data());
} catch (Exception ex) {
throw convertSrpAccessException(ex);
}
}
public Boolean getBit(byte[] key, long offset) {
try {
if (isPipelined()) {
@@ -1832,6 +1845,17 @@ public class SrpConnection implements RedisConnection {
}
}
public Double hIncrBy(byte[] key, byte[] field, double delta) {
try {
if (isPipelined()) {
pipeline(pipeline.hincrbyfloat(key, field, delta));
return null;
}
return SrpUtils.toDouble(client.hincrbyfloat(key, field, delta).data());
} catch (Exception ex) {
throw convertSrpAccessException(ex);
}
}
public Set<byte[]> hKeys(byte[] key) {
try {