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

Function moduleScanKeyCallback

app/redis-6.2.6/src/module.c:7705–7724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7703} ScanKeyCBData;
7704
7705static void moduleScanKeyCallback(void *privdata, const dictEntry *de) {
7706 ScanKeyCBData *data = privdata;
7707 sds key = dictGetKey(de);
7708 robj *o = data->key->value;
7709 robj *field = createStringObject(key, sdslen(key));
7710 robj *value = NULL;
7711 if (o->type == OBJ_SET) {
7712 value = NULL;
7713 } else if (o->type == OBJ_HASH) {
7714 sds val = dictGetVal(de);
7715 value = createStringObject(val, sdslen(val));
7716 } else if (o->type == OBJ_ZSET) {
7717 double *val = (double*)dictGetVal(de);
7718 value = createStringObjectFromLongDouble(*val, 0);
7719 }
7720
7721 data->fn(data->key, field, value, data->user_data);
7722 decrRefCount(field);
7723 if (value) decrRefCount(value);
7724}
7725
7726/* Scan api that allows a module to scan the elements in a hash, set or sorted set key
7727 *

Callers

nothing calls this directly

Calls 4

sdslenFunction · 0.85
decrRefCountFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected