MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / catCommandForAofAndActiveReplication

Function catCommandForAofAndActiveReplication

src/aof.cpp:682–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682sds catCommandForAofAndActiveReplication(sds buf, struct redisCommand *cmd, robj **argv, int argc)
683{
684 if (cmd->proc == expireCommand || cmd->proc == pexpireCommand ||
685 cmd->proc == expireatCommand) {
686 /* Translate EXPIRE/PEXPIRE/EXPIREAT into PEXPIREAT */
687 buf = catAppendOnlyExpireAtCommand(buf,cmd,argv[1],argv[2]);
688 } else if (cmd->proc == setCommand && argc > 3) {
689 robj *pxarg = NULL;
690 /* When SET is used with EX/PX argument setGenericCommand propagates them with PX millisecond argument.
691 * So since the command arguments are re-written there, we can rely here on the index of PX being 3. */
692 if (!strcasecmp(szFromObj(argv[3]), "px")) {
693 pxarg = argv[4];
694 }
695 /* For AOF we convert SET key value relative time in milliseconds to SET key value absolute time in
696 * millisecond. Whenever the condition is true it implies that original SET has been transformed
697 * to SET PX with millisecond time argument so we do not need to worry about unit here.*/
698 if (pxarg) {
699 robj *millisecond = getDecodedObject(pxarg);
700 long long when = strtoll(szFromObj(millisecond),NULL,10);
701 when += mstime();
702
703 decrRefCount(millisecond);
704
705 robj *newargs[5];
706 newargs[0] = argv[0];
707 newargs[1] = argv[1];
708 newargs[2] = argv[2];
709 newargs[3] = shared.pxat;
710 newargs[4] = createStringObjectFromLongLong(when);
711 buf = catAppendOnlyGenericCommand(buf,5,newargs);
712 decrRefCount(newargs[4]);
713 } else {
714 buf = catAppendOnlyGenericCommand(buf,argc,argv);
715 }
716 } else if (cmd->proc == expireMemberCommand || cmd->proc == expireMemberAtCommand || cmd->proc == pexpireMemberAtCommand) {
717 /* Translate subkey expire commands to PEXPIREMEMBERAT */
718 buf = catAppendOnlyExpireMemberAtCommand(buf, cmd, argv, argc);
719 } else {
720 /* All the other commands don't need translation or need the
721 * same translation already operated in the command vector
722 * for the replication itself. */
723 buf = catAppendOnlyGenericCommand(buf,argc,argv);
724 }
725
726 return buf;
727}
728
729void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int argc) {
730 sds buf = sdsempty();

Callers 3

replicationFeedSlaveFunction · 0.85
feedAppendOnlyFileFunction · 0.85

Calls 8

szFromObjFunction · 0.85
getDecodedObjectFunction · 0.85
decrRefCountFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected