Skip to content

Commit

Permalink
Merge branch 'main' into 7.4-support-hexpire
Browse files Browse the repository at this point in the history
  • Loading branch information
moticless committed Jun 13, 2024
2 parents 618ccd0 + 46049a1 commit c99f278
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ext/handlersToJson.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static RdbRes toJsonDbSize(RdbParser *p, void *userData, uint64_t db_size, uint6
}

/* output json part */
fprintf(ctx->outfile, " \"__dbsize__\": {\n");
fprintf(ctx->outfile, " \"%sdbsize__\": {\n", jsonMetaPrefix); /* group dbsize with {..} */
fprintf(ctx->outfile, " \"size\": %" PRIu64 ",\n", db_size);
fprintf(ctx->outfile, " \"expires\": %" PRIu64 "\n", exp_size);
fprintf(ctx->outfile, " }%s\n", (db_size) ? "," : "");
Expand All @@ -171,7 +171,7 @@ static RdbRes toJsonSlotInfo(RdbParser *p, void *userData, RdbSlotInfo *info) {
}

/* output json part */
fprintf(ctx->outfile, " \"__slotinfo__\": {\n");
fprintf(ctx->outfile, " \"%sslotinfo__\": {\n", jsonMetaPrefix);
fprintf(ctx->outfile, " \"slotId\": %lu,\n", info->slot_id);
fprintf(ctx->outfile, " \"slotSize\": %lu,\n", info->slot_size);
fprintf(ctx->outfile, " \"slotSExpiresSize\": %lu\n", info->expires_slot_size);
Expand All @@ -184,7 +184,7 @@ static RdbRes toJsonAuxField(RdbParser *p, void *userData, RdbBulk auxkey, RdbBu

if (ctx->state == R2J_IDLE) {
ctx->state = R2J_AUX_FIELDS;
fprintf(ctx->outfile, "\"__aux__\" : {\n "); /* group aux-fields with { ... } */
fprintf(ctx->outfile, " \"%saux__\": {\n", jsonMetaPrefix); /* group aux-fields with {..} */
} else if (ctx->state == R2J_AUX_FIELDS) {
fprintf(ctx->outfile, ",\n ");
} else {
Expand Down Expand Up @@ -503,9 +503,9 @@ static RdbRes toJsonFunction(RdbParser *p, void *userData, RdbBulk func) {

if (ctx->state == R2J_IDLE) {
ctx->state = R2J_FUNCTIONS;
fprintf(ctx->outfile, "\"__func__\": {\n");
fprintf(ctx->outfile, "\"%sfunc__\": {\n", jsonMetaPrefix);
} else if (ctx->state == R2J_AUX_FIELDS) {
fprintf(ctx->outfile, "\n},\n \"__func__\": {\n");
fprintf(ctx->outfile, "\n},\n \"%sfunc__\": {\n", jsonMetaPrefix);
ctx->state = R2J_FUNCTIONS;
} else if (ctx->state == R2J_FUNCTIONS) {
fprintf(ctx->outfile, ",\n");
Expand Down
8 changes: 8 additions & 0 deletions test/dumps/plain_hash_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"__aux__" : {
"redis-ver":"3.2.1",
"redis-bits":"64",
"ctime":"1689605183",
"used-mem":"821904"
},

"myhash1":{"5":"5","6":"6","10":"10","1":"1","2":"2","8":"8","4":"4","9":"9","3":"3","7":"7","11":"11"}
8 changes: 8 additions & 0 deletions test/dumps/plain_hash_struct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"__aux__" : {
"redis-ver":"3.2.1",
"redis-bits":"64",
"ctime":"1689605183",
"used-mem":"821904"
},

"myhash1":{"5":"5","6":"6","10":"10","1":"1","2":"2","8":"8","4":"4","9":"9","3":"3","7":"7","11":"11"}

0 comments on commit c99f278

Please sign in to comment.