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

Function feedAppendOnlyFile

src/aof.cpp:729–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727}
728
729void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int argc) {
730 sds buf = sdsempty();
731
732 /* The DB this command was targeting is not the same as the last command
733 * we appended. To issue a SELECT command is needed. */
734 if (dictid != g_pserver->aof_selected_db) {
735 char seldb[64];
736
737 snprintf(seldb,sizeof(seldb),"%d",dictid);
738 buf = sdscatprintf(buf,"*2\r\n$6\r\nSELECT\r\n$%lu\r\n%s\r\n",
739 (unsigned long)strlen(seldb),seldb);
740 g_pserver->aof_selected_db = dictid;
741 }
742
743 buf = catCommandForAofAndActiveReplication(buf, cmd, argv, argc);
744
745 /* Append to the AOF buffer. This will be flushed on disk just before
746 * of re-entering the event loop, so before the client will get a
747 * positive reply about the operation performed. */
748 if (g_pserver->aof_state == AOF_ON)
749 g_pserver->aof_buf = sdscatlen(g_pserver->aof_buf,buf,sdslen(buf));
750
751 /* If a background append only file rewriting is in progress we want to
752 * accumulate the differences between the child DB and the current one
753 * in a buffer, so that when the child process will do its work we
754 * can append the differences to the new append only file. */
755 if (hasActiveChildProcess() && g_pserver->child_type == CHILD_TYPE_AOF)
756 aofRewriteBufferAppend((unsigned char*)buf,sdslen(buf));
757
758 sdsfree(buf);
759}
760
761/* ----------------------------------------------------------------------------
762 * AOF loading

Callers 3

propagateSubkeyExpireFunction · 0.85
propagateFunction · 0.85
executeCronJobExpireHookFunction · 0.85

Calls 8

sdsemptyFunction · 0.85
sdscatprintfFunction · 0.85
sdscatlenFunction · 0.85
sdslenFunction · 0.85
hasActiveChildProcessFunction · 0.85
aofRewriteBufferAppendFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected