INCRBY/DECRBY now support 64bit increments, with tests

This commit is contained in:
antirez 2009-04-27 17:50:26 +02:00
parent f5785ae997
commit d68ed1201a
4 changed files with 21 additions and 4 deletions

View File

@ -1,3 +1,5 @@
2009-04-23 RANDOMKEY regression test added
2009-04-23 dictGetRandomKey bug fixed, RANDOMKEY will not block the server anymore
2009-04-22 FLUSHALL/FLUSHDB no longer sync on disk. Just increment the dirty counter by the number of elements removed, that will probably trigger a background saving operation
2009-04-21 forgot to comment testing code in PHP lib. Now it is ok
2009-04-21 PHP client ported to PHP5 and fixed

2
TODO
View File

@ -1,7 +1,6 @@
BEFORE REDIS 1.0.0-rc1
- What happens if the saving child gets killed instead to end normally? Handle this.
- Fix INCRBY argument that is limited to 32bit int.
- Make sinterstore / unionstore / sdiffstore returning the cardinality of the resulting set.
- Add a new field as INFO output: bgsaveinprogress
- Remove max number of args limit
@ -24,6 +23,7 @@ This command should be smart and don't use too much memory, that is, take two co
- Document replication
- Objects sharing configuration, add the directive "objectsharingpool <size>"
- Make sure to convert all the fstat() calls to 64bit versions.
- SINTERCOUNT, SUNIONCOUNT, SDIFFCOUNT
FUTURE HINTS

View File

@ -2195,7 +2195,7 @@ static void mgetCommand(redisClient *c) {
}
}
static void incrDecrCommand(redisClient *c, int incr) {
static void incrDecrCommand(redisClient *c, long long incr) {
long long value;
int retval;
robj *o;
@ -2237,12 +2237,12 @@ static void decrCommand(redisClient *c) {
}
static void incrbyCommand(redisClient *c) {
int incr = atoi(c->argv[2]->ptr);
long long incr = strtoll(c->argv[2]->ptr, NULL, 10);
incrDecrCommand(c,incr);
}
static void decrbyCommand(redisClient *c) {
int incr = atoi(c->argv[2]->ptr);
long long incr = strtoll(c->argv[2]->ptr, NULL, 10);
incrDecrCommand(c,-incr);
}

View File

@ -101,6 +101,21 @@ proc main {server port} {
$r incr novar
} {101}
test {INCR over 32bit value} {
$r set novar 17179869184
$r incr novar
} {17179869185}
test {INCRBY over 32bit value with over 32bit increment} {
$r set novar 17179869184
$r incrby novar 17179869184
} {34359738368}
test {DECRBY over 32bit value with over 32bit increment, negative res} {
$r set novar 17179869184
$r decrby novar 17179869185
} {-1}
test {SETNX target key missing} {
$r setnx novar2 foobared
$r get novar2