Add Redis 2.6 hincrbyfloat to RedisMap and HashOperations
DATAREDIS-181
This commit is contained in:
@@ -33,6 +33,8 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
|
||||
|
||||
Long increment(HK key, long delta);
|
||||
|
||||
Double increment(HK key, double delta);
|
||||
|
||||
HV get(Object key);
|
||||
|
||||
void put(HK key, HV value);
|
||||
|
||||
@@ -72,7 +72,10 @@ class DefaultBoundHashOperations<H, HK, HV> extends DefaultBoundKeyOperations<H>
|
||||
return ops.increment(getKey(), key, delta);
|
||||
}
|
||||
|
||||
|
||||
public Double increment(HK key, double delta) {
|
||||
return ops.increment(getKey(), key, delta);
|
||||
}
|
||||
|
||||
public Set<HK> keys() {
|
||||
return ops.keys(getKey());
|
||||
}
|
||||
|
||||
@@ -79,7 +79,17 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Double increment(K key, HK hashKey, final double delta) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
|
||||
return execute(new RedisCallback<Double>() {
|
||||
public Double doInRedis(RedisConnection connection) {
|
||||
return connection.hIncrBy(rawKey, rawHashKey, delta);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
public Set<HK> keys(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ public interface HashOperations<H, HK, HV> {
|
||||
|
||||
Long increment(H key, HK hashKey, long delta);
|
||||
|
||||
Double increment(H key, HK hashKey, double delta);
|
||||
|
||||
Set<HK> keys(H key);
|
||||
|
||||
Long size(H key);
|
||||
|
||||
@@ -89,7 +89,11 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
public Long increment(K key, long delta) {
|
||||
return hashOps.increment(key, delta);
|
||||
}
|
||||
|
||||
|
||||
public Double increment(K key, double delta) {
|
||||
return hashOps.increment(key, delta);
|
||||
}
|
||||
|
||||
public RedisOperations<String, ?> getOperations() {
|
||||
return hashOps.getOperations();
|
||||
}
|
||||
|
||||
@@ -26,4 +26,6 @@ import java.util.concurrent.ConcurrentMap;
|
||||
public interface RedisMap<K, V> extends RedisStore, ConcurrentMap<K, V> {
|
||||
|
||||
Long increment(K key, long delta);
|
||||
|
||||
Double increment(K key, double delta);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -209,8 +208,11 @@ public class RedisProperties extends Properties implements RedisMap<Object, Obje
|
||||
public Long increment(Object key, long delta) {
|
||||
return hashOps.increment((String) key, delta);
|
||||
}
|
||||
|
||||
|
||||
public Double increment(Object key, double delta) {
|
||||
return hashOps.increment((String) key, delta);
|
||||
}
|
||||
|
||||
public RedisOperations<String, ?> getOperations() {
|
||||
return hashOps.getOperations();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user