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

Function keysCommand

app/redis-6.2.6/src/db.c:749–774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747}
748
749void keysCommand(client *c) {
750 dictIterator *di;
751 dictEntry *de;
752 sds pattern = c->argv[1]->ptr;
753 int plen = sdslen(pattern), allkeys;
754 unsigned long numkeys = 0;
755 void *replylen = addReplyDeferredLen(c);
756
757 di = dictGetSafeIterator(c->db->dict);
758 allkeys = (pattern[0] == '*' && plen == 1);
759 while((de = dictNext(di)) != NULL) {
760 sds key = dictGetKey(de);
761 robj *keyobj;
762
763 if (allkeys || stringmatchlen(pattern,plen,key,sdslen(key),0)) {
764 keyobj = createStringObject(key,sdslen(key));
765 if (!keyIsExpired(c->db,keyobj)) {
766 addReplyBulk(c,keyobj);
767 numkeys++;
768 }
769 decrRefCount(keyobj);
770 }
771 }
772 dictReleaseIterator(di);
773 setDeferredArrayLen(c,replylen,numkeys);
774}
775
776/* This callback is used by scanGenericCommand in order to collect elements
777 * returned by the dictionary iterator into a list. */

Callers

nothing calls this directly

Calls 11

sdslenFunction · 0.85
addReplyDeferredLenFunction · 0.85
dictGetSafeIteratorFunction · 0.85
stringmatchlenFunction · 0.85
keyIsExpiredFunction · 0.85
addReplyBulkFunction · 0.85
decrRefCountFunction · 0.85
setDeferredArrayLenFunction · 0.85
dictNextFunction · 0.70
createStringObjectFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected