Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moticless committed Oct 14, 2024
1 parent 602f61b commit cefdadd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/t_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,12 @@ void spopCommand(client *c) {
if ((set = lookupKeyWriteOrReply(c,c->argv[1],shared.null[c->resp]))
== NULL || checkType(c,set,OBJ_SET)) return;

size = setTypeSize(set);
updateKeysizesHist(c->db, getKeySlot(c->argv[1]->ptr), OBJ_SET, size, size-1);

/* Pop a random element from the set */
ele = setTypePopRandom(set);

size = setTypeSize(set);
updateKeysizesHist(c->db, getKeySlot(c->argv[1]->ptr), OBJ_SET, size + 1, size);
notifyKeyspaceEvent(NOTIFY_SET,"spop",c->argv[1],c->db->id);

/* Replicate/AOF this command as an SREM operation */
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/info-keysizes.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ start_server {} {
run_cmd_verify_hist {r FLUSHALL} {}
# SADD
run_cmd_verify_hist {r SADD s1 1 2 3 4 5} {db0_SET:4=1}
run_cmd_verify_hist {r SADD s1 6 7 8 9} {db0_SET:8=1}
run_cmd_verify_hist {r SADD s1 6 7 8} {db0_SET:8=1}
# Test also SADD, SREM, SMOVE, SPOP
run_cmd_verify_hist {r SADD s2 1} {db0_SET:1=1,8=1}
run_cmd_verify_hist {r SADD s2 2} {db0_SET:2=1,8=1}
run_cmd_verify_hist {r SREM s2 3} {db0_SET:2=1,8=1}
run_cmd_verify_hist {r SMOVE s2 s3 2} {db0_SET:1=2,8=1}
run_cmd_verify_hist {r SPOP s3} {db0_SET:1=1,8=1}
run_cmd_verify_hist {r SPOP s3} {db0_SET:8=1}
run_cmd_verify_hist {r SPOP s3} {}
run_cmd_verify_hist {r SPOP s2} {db0_SET:8=1}
run_cmd_verify_hist {r SPOP s1} {db0_SET:4=1}
run_cmd_verify_hist {r del s1} {}

# SDIFFSTORE
run_cmd_verify_hist {r flushall} {}
Expand Down

0 comments on commit cefdadd

Please sign in to comment.