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

Function zrankGenericCommand

src/t_zset.cpp:3762–3778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3760}
3761
3762void zrankGenericCommand(client *c, int reverse) {
3763 robj *key = c->argv[1];
3764 robj *ele = c->argv[2];
3765 robj_roptr zobj;
3766 long rank;
3767
3768 if ((zobj = lookupKeyReadOrReply(c,key,shared.null[c->resp])) == nullptr ||
3769 checkType(c,zobj,OBJ_ZSET)) return;
3770
3771 serverAssertWithInfo(c,ele,sdsEncodedObject(ele));
3772 rank = zsetRank(zobj,szFromObj(ele),reverse);
3773 if (rank >= 0) {
3774 addReplyLongLong(c,rank);
3775 } else {
3776 addReplyNull(c);
3777 }
3778}
3779
3780void zrankCommand(client *c) {
3781 zrankGenericCommand(c, 0);

Callers 2

zrankCommandFunction · 0.85
zrevrankCommandFunction · 0.85

Calls 6

lookupKeyReadOrReplyFunction · 0.85
checkTypeFunction · 0.85
zsetRankFunction · 0.85
szFromObjFunction · 0.85
addReplyLongLongFunction · 0.85
addReplyNullFunction · 0.85

Tested by

no test coverage detected