mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
previouse INCR implementation restored, was actually faster for some reson not fully clear at the moment
This commit is contained in:
parent
d6107fd6f1
commit
afd438dfff
@ -144,24 +144,8 @@ void incrDecrCommand(redisClient *c, long long incr) {
|
|||||||
|
|
||||||
o = lookupKeyWrite(c->db,c->argv[1]);
|
o = lookupKeyWrite(c->db,c->argv[1]);
|
||||||
if (o != NULL && checkType(c,o,REDIS_STRING)) return;
|
if (o != NULL && checkType(c,o,REDIS_STRING)) return;
|
||||||
|
|
||||||
/* Fast path if the object is integer encoded and is not shared. */
|
|
||||||
if (o && o->refcount == 1 && o->encoding == REDIS_ENCODING_INT) {
|
|
||||||
long long newval = ((long)o->ptr) + incr;
|
|
||||||
|
|
||||||
if (newval < 0 && newval >= REDIS_SHARED_INTEGERS &&
|
|
||||||
newval >= LONG_MIN && newval <= LONG_MAX) {
|
|
||||||
o->ptr = (void*) (long) newval;
|
|
||||||
touchWatchedKey(c->db,c->argv[1]);
|
|
||||||
server.dirty++;
|
|
||||||
addReplyLongLong(c,newval);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* ... else take the usual safe path */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise we create a new object and replace the old one. */
|
|
||||||
if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return;
|
if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return;
|
||||||
|
|
||||||
value += incr;
|
value += incr;
|
||||||
o = createStringObjectFromLongLong(value);
|
o = createStringObjectFromLongLong(value);
|
||||||
dbReplace(c->db,c->argv[1],o);
|
dbReplace(c->db,c->argv[1],o);
|
||||||
|
Loading…
Reference in New Issue
Block a user