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

Function RM_Scan

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

Scan API that allows a module to scan all the keys and value in * the selected db. * * Callback for scan implementation. * * void scan_callback(RedisModuleCtx *ctx, RedisModuleString *keyname, * RedisModuleKey *key, void *privdata); * * - `ctx`: the redis module context provided to for the scan. * - `keyname`: owned by the caller and need to be retained if used

Source from the content-addressed store, hash-verified

7680 * memory, so it may make sense to just operate on the current key when
7681 * possible during the iteration, given that this is safe. */
7682int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) {
7683 if (cursor->done) {
7684 errno = ENOENT;
7685 return 0;
7686 }
7687 int ret = 1;
7688 ScanCBData data = { ctx, privdata, fn };
7689 cursor->cursor = dictScan(ctx->client->db->dict, cursor->cursor, moduleScanCallback, NULL, &data);
7690 if (cursor->cursor == 0) {
7691 cursor->done = 1;
7692 ret = 0;
7693 }
7694 errno = 0;
7695 return ret;
7696}
7697
7698typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata);
7699typedef struct {

Callers

nothing calls this directly

Calls 1

dictScanFunction · 0.85

Tested by

no test coverage detected