MCPcopy Create free account
hub / github.com/F-Stack/f-stack / blockingGenericZpopCommand

Function blockingGenericZpopCommand

app/redis-6.2.6/src/t_zset.c:3945–3978  ·  view source on GitHub ↗

BZPOPMIN / BZPOPMAX actual implementation. */

Source from the content-addressed store, hash-verified

3943
3944/* BZPOPMIN / BZPOPMAX actual implementation. */
3945void blockingGenericZpopCommand(client *c, int where) {
3946 robj *o;
3947 mstime_t timeout;
3948 int j;
3949
3950 if (getTimeoutFromObjectOrReply(c,c->argv[c->argc-1],&timeout,UNIT_SECONDS)
3951 != C_OK) return;
3952
3953 for (j = 1; j < c->argc-1; j++) {
3954 o = lookupKeyWrite(c->db,c->argv[j]);
3955 if (checkType(c,o,OBJ_ZSET)) return;
3956 if (o != NULL) {
3957 if (zsetLength(o) != 0) {
3958 /* Non empty zset, this is like a normal ZPOP[MIN|MAX]. */
3959 genericZpopCommand(c,&c->argv[j],1,where,1,NULL);
3960 /* Replicate it as an ZPOP[MIN|MAX] instead of BZPOP[MIN|MAX]. */
3961 rewriteClientCommandVector(c,2,
3962 where == ZSET_MAX ? shared.zpopmax : shared.zpopmin,
3963 c->argv[j]);
3964 return;
3965 }
3966 }
3967 }
3968
3969 /* If we are not allowed to block the client and the zset is empty the only thing
3970 * we can do is treating it as a timeout (even with timeout 0). */
3971 if (c->flags & CLIENT_DENY_BLOCKING) {
3972 addReplyNullArray(c);
3973 return;
3974 }
3975
3976 /* If the keys do not exist we must block */
3977 blockForKeys(c,BLOCKED_ZSET,c->argv + 1,c->argc - 2,timeout,NULL,NULL,NULL);
3978}
3979
3980// BZPOPMIN key [key ...] timeout
3981void bzpopminCommand(client *c) {

Callers 2

bzpopminCommandFunction · 0.85
bzpopmaxCommandFunction · 0.85

Calls 8

lookupKeyWriteFunction · 0.85
checkTypeFunction · 0.85
zsetLengthFunction · 0.85
genericZpopCommandFunction · 0.85
addReplyNullArrayFunction · 0.85
blockForKeysFunction · 0.85

Tested by

no test coverage detected