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

Function sendScan

src/redis-cli.c:6542–6574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6540 *--------------------------------------------------------------------------- */
6541
6542redisReply *sendScan(unsigned long long *it) {
6543 redisReply *reply;
6544
6545 if (config.pattern)
6546 reply = redisCommand(context, "SCAN %llu MATCH %b",
6547 *it, config.pattern, sdslen(config.pattern));
6548 else
6549 reply = redisCommand(context,"SCAN %llu",*it);
6550
6551 /* Handle any error conditions */
6552 if(reply == NULL) {
6553 fprintf(stderr, "\nI/O error\n");
6554 exit(1);
6555 } else if(reply->type == REDIS_REPLY_ERROR) {
6556 fprintf(stderr, "SCAN error: %s\n", reply->str);
6557 exit(1);
6558 } else if(reply->type != REDIS_REPLY_ARRAY) {
6559 fprintf(stderr, "Non ARRAY response from SCAN!\n");
6560 exit(1);
6561 } else if(reply->elements != 2) {
6562 fprintf(stderr, "Invalid element count from SCAN!\n");
6563 exit(1);
6564 }
6565
6566 /* Validate our types are correct */
6567 assert(reply->element[0]->type == REDIS_REPLY_STRING);
6568 assert(reply->element[1]->type == REDIS_REPLY_ARRAY);
6569
6570 /* Update iterator */
6571 *it = strtoull(reply->element[0]->str, NULL, 10);
6572
6573 return reply;
6574}
6575
6576int getDbSize(void) {
6577 redisReply *reply;

Callers 3

findHotKeysFunction · 0.85
scanModeFunction · 0.85
findBigKeysFunction · 0.85

Calls 2

sdslenFunction · 0.85
redisCommandClass · 0.70

Tested by

no test coverage detected