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

Function rdbSaveSingleModuleAux

src/rdb.cpp:1265–1304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263}
1264
1265ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) {
1266 /* Save a module-specific aux value. */
1267 RedisModuleIO io;
1268 int retval = rdbSaveType(rdb, RDB_OPCODE_MODULE_AUX);
1269 if (retval == -1) return -1;
1270 moduleInitIOContext(io,mt,rdb,NULL);
1271 io.bytes += retval;
1272
1273 /* Write the "module" identifier as prefix, so that we'll be able
1274 * to call the right module during loading. */
1275 retval = rdbSaveLen(rdb,mt->id);
1276 if (retval == -1) return -1;
1277 io.bytes += retval;
1278
1279 /* write the 'when' so that we can provide it on loading. add a UINT opcode
1280 * for backwards compatibility, everything after the MT needs to be prefixed
1281 * by an opcode. */
1282 retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_UINT);
1283 if (retval == -1) return -1;
1284 io.bytes += retval;
1285 retval = rdbSaveLen(rdb,when);
1286 if (retval == -1) return -1;
1287 io.bytes += retval;
1288
1289 /* Then write the module-specific representation + EOF marker. */
1290 mt->aux_save(&io,when);
1291 retval = rdbSaveLen(rdb,RDB_MODULE_OPCODE_EOF);
1292 if (retval == -1)
1293 io.error = 1;
1294 else
1295 io.bytes += retval;
1296
1297 if (io.ctx) {
1298 moduleFreeContext(io.ctx);
1299 zfree(io.ctx);
1300 }
1301 if (io.error)
1302 return -1;
1303 return io.bytes;
1304}
1305
1306/* Produces a dump of the database in RDB format sending it to the specified
1307 * Redis I/O channel. On success C_OK is returned, otherwise C_ERR

Callers 1

rdbSaveModulesAuxFunction · 0.85

Calls 4

rdbSaveTypeFunction · 0.85
rdbSaveLenFunction · 0.85
moduleFreeContextFunction · 0.85
zfreeFunction · 0.85

Tested by

no test coverage detected