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

Function zremCommand

src/t_zset.cpp:1855–1880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1853}
1854
1855void zremCommand(client *c) {
1856 robj *key = c->argv[1];
1857 robj *zobj;
1858 int deleted = 0, keyremoved = 0, j;
1859
1860 if ((zobj = lookupKeyWriteOrReply(c,key,shared.czero)) == NULL ||
1861 checkType(c,zobj,OBJ_ZSET)) return;
1862
1863 for (j = 2; j < c->argc; j++) {
1864 if (zsetDel(zobj,szFromObj(c->argv[j]))) deleted++;
1865 if (zsetLength(zobj) == 0) {
1866 dbDelete(c->db,key);
1867 keyremoved = 1;
1868 break;
1869 }
1870 }
1871
1872 if (deleted) {
1873 notifyKeyspaceEvent(NOTIFY_ZSET,"zrem",key,c->db->id);
1874 if (keyremoved)
1875 notifyKeyspaceEvent(NOTIFY_GENERIC,"del",key,c->db->id);
1876 signalModifiedKey(c,c->db,key);
1877 g_pserver->dirty += deleted;
1878 }
1879 addReplyLongLong(c,deleted);
1880}
1881
1882typedef enum {
1883 ZRANGE_AUTO = 0,

Callers

nothing calls this directly

Calls 9

lookupKeyWriteOrReplyFunction · 0.85
checkTypeFunction · 0.85
zsetDelFunction · 0.85
szFromObjFunction · 0.85
zsetLengthFunction · 0.85
dbDeleteFunction · 0.85
notifyKeyspaceEventFunction · 0.85
signalModifiedKeyFunction · 0.85
addReplyLongLongFunction · 0.85

Tested by

no test coverage detected