Add Redis 2.6 incrbyfloat to ValueOperations
DATAREDIS-181
This commit is contained in:
@@ -42,6 +42,8 @@ public interface BoundValueOperations<K, V> extends BoundKeyOperations<K> {
|
||||
|
||||
Long increment(long delta);
|
||||
|
||||
Double increment(double delta);
|
||||
|
||||
Integer append(String value);
|
||||
|
||||
Long size();
|
||||
|
||||
@@ -52,7 +52,10 @@ class DefaultBoundValueOperations<K, V> extends DefaultBoundKeyOperations<K> imp
|
||||
return ops.increment(getKey(), delta);
|
||||
}
|
||||
|
||||
|
||||
public Double increment(double delta) {
|
||||
return ops.increment(getKey(), delta);
|
||||
}
|
||||
|
||||
public Integer append(String value) {
|
||||
return ops.append(getKey(), value);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.data.redis.connection.RedisConnection;
|
||||
* Default implementation of {@link ValueOperations}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
*/
|
||||
class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements ValueOperations<K, V> {
|
||||
|
||||
@@ -61,24 +62,23 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
|
||||
public Long increment(K key, final long delta) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
// TODO add conversion service in here ?
|
||||
return execute(new RedisCallback<Long>() {
|
||||
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
if (delta == 1) {
|
||||
return connection.incr(rawKey);
|
||||
}
|
||||
|
||||
if (delta == -1) {
|
||||
return connection.decr(rawKey);
|
||||
}
|
||||
|
||||
return connection.incrBy(rawKey, delta);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
public Double increment(K key, final double delta) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
return execute(new RedisCallback<Double>() {
|
||||
public Double doInRedis(RedisConnection connection) {
|
||||
return connection.incrBy(rawKey, delta);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
public Integer append(K key, String value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawString = rawString(value);
|
||||
|
||||
@@ -45,6 +45,8 @@ public interface ValueOperations<K, V> {
|
||||
|
||||
Long increment(K key, long delta);
|
||||
|
||||
Double increment(K key, double delta);
|
||||
|
||||
Integer append(K key, String value);
|
||||
|
||||
String get(K key, long start, long end);
|
||||
|
||||
Reference in New Issue
Block a user