MCPcopy Create free account
hub / github.com/F-Stack/f-stack / incrbyfloatCommand

Function incrbyfloatCommand

app/redis-6.2.6/src/t_string.c:639–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637}
638
639void incrbyfloatCommand(client *c) {
640 long double incr, value;
641 robj *o, *new;
642
643 o = lookupKeyWrite(c->db,c->argv[1]);
644 if (checkType(c,o,OBJ_STRING)) return;
645 if (getLongDoubleFromObjectOrReply(c,o,&value,NULL) != C_OK ||
646 getLongDoubleFromObjectOrReply(c,c->argv[2],&incr,NULL) != C_OK)
647 return;
648
649 value += incr;
650 if (isnan(value) || isinf(value)) {
651 addReplyError(c,"increment would produce NaN or Infinity");
652 return;
653 }
654 new = createStringObjectFromLongDouble(value,1);
655 if (o)
656 dbOverwrite(c->db,c->argv[1],new);
657 else
658 dbAdd(c->db,c->argv[1],new);
659 signalModifiedKey(c,c->db,c->argv[1]);
660 notifyKeyspaceEvent(NOTIFY_STRING,"incrbyfloat",c->argv[1],c->db->id);
661 server.dirty++;
662 addReplyBulk(c,new);
663
664 /* Always replicate INCRBYFLOAT as a SET command with the final value
665 * in order to make sure that differences in float precision or formatting
666 * will not create differences in replicas or after an AOF restart. */
667 rewriteClientCommandArgument(c,0,shared.set);
668 rewriteClientCommandArgument(c,2,new);
669 rewriteClientCommandArgument(c,3,shared.keepttl);
670}
671
672void appendCommand(client *c) {
673 size_t totlen;

Callers

nothing calls this directly

Calls 11

lookupKeyWriteFunction · 0.85
checkTypeFunction · 0.85
addReplyErrorFunction · 0.85
dbOverwriteFunction · 0.85
dbAddFunction · 0.85
signalModifiedKeyFunction · 0.85
notifyKeyspaceEventFunction · 0.85
addReplyBulkFunction · 0.85

Tested by

no test coverage detected