Manually merge #400
This commit is contained in:
@@ -634,6 +634,36 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
/**
|
||||
* INCRBYFLOAT work just like {@link #incrBy(byte[]) INCRBY} but increments
|
||||
* by floats instead of integers.
|
||||
* <p>
|
||||
* INCRBYFLOAT commands are limited to double precision floating point values.
|
||||
* <p>
|
||||
* Note: this is actually a string operation, that is, in Redis there are
|
||||
* not "double" types. Simply the string stored at the key is parsed as a
|
||||
* base double precision floating point value, incremented, and then converted
|
||||
* back as a string. There is no DECRYBYFLOAT but providing a negative
|
||||
* value will work as expected.
|
||||
* <p>
|
||||
* Time complexity: O(1)
|
||||
*
|
||||
* @see #incr(byte[])
|
||||
* @see #decr(byte[])
|
||||
* @see #decrBy(byte[], long)
|
||||
*
|
||||
* @param key
|
||||
* @param integer
|
||||
* @return Integer reply, this commands will reply with the new value of key
|
||||
* after the increment.
|
||||
*/
|
||||
public Double incrByFloat(final byte[] key, final double integer) {
|
||||
checkIsInMulti();
|
||||
client.incrByFloat(key, integer);
|
||||
String dval = client.getBulkReply();
|
||||
return (dval != null ? new Double(dval) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the number stored at key by one. If the key does not exist or
|
||||
* contains a value of a wrong type, set the key to the value of "0" before
|
||||
@@ -826,6 +856,32 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the number stored at field in the hash at key by a double
|
||||
* precision floating point value. If key does not exist,
|
||||
* a new key holding a hash is created. If field does not
|
||||
* exist or holds a string, the value is set to 0 before applying the
|
||||
* operation. Since the value argument is signed you can use this command to
|
||||
* perform both increments and decrements.
|
||||
* <p>
|
||||
* The range of values supported by HINCRBYFLOAT is limited to
|
||||
* double precision floating point values.
|
||||
* <p>
|
||||
* <b>Time complexity:</b> O(1)
|
||||
*
|
||||
* @param key
|
||||
* @param field
|
||||
* @param value
|
||||
* @return Double precision floating point reply The new value at field after the increment
|
||||
* operation.
|
||||
*/
|
||||
public Double hincrByFloat(final byte[] key, final byte[] field, final double value) {
|
||||
checkIsInMulti();
|
||||
client.hincrByFloat(key, field, value);
|
||||
final String dval = client.getBulkReply();
|
||||
return (dval != null ? new Double(dval) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for existence of a specified field in a hash.
|
||||
*
|
||||
@@ -3347,13 +3403,6 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Double incrByFloat(final byte[] key, final double increment) {
|
||||
checkIsInMulti();
|
||||
client.incrByFloat(key, increment);
|
||||
String relpy = client.getBulkReply();
|
||||
return (relpy != null ? new Double(relpy) : null);
|
||||
}
|
||||
|
||||
public String psetex(final byte[] key, final int milliseconds,
|
||||
final byte[] value) {
|
||||
checkIsInMulti();
|
||||
@@ -3411,14 +3460,6 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public Double hincrByFloat(final byte[] key, final byte[] field,
|
||||
double increment) {
|
||||
checkIsInMulti();
|
||||
client.hincrByFloat(key, field, increment);
|
||||
String relpy = client.getBulkReply();
|
||||
return (relpy != null ? new Double(relpy) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Syncrhonous replication of Redis as described here:
|
||||
* http://antirez.com/news/66
|
||||
|
||||
Reference in New Issue
Block a user