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

Function RM_Scan

src/module.cpp:7877–7891  ·  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

7875 * memory, so it may make sense to just operate on the current key when
7876 * possible during the iteration, given that this is safe. */
7877int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) {
7878 if (cursor->done) {
7879 errno = ENOENT;
7880 return 0;
7881 }
7882 int ret = 1;
7883 ScanCBData data = { ctx, privdata, fn };
7884 cursor->cursor = dictScan(ctx->client->db->dictUnsafeKeyOnly(), cursor->cursor, moduleScanCallback, NULL, &data);
7885 if (cursor->cursor == 0) {
7886 cursor->done = 1;
7887 ret = 0;
7888 }
7889 errno = 0;
7890 return ret;
7891}
7892
7893typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata);
7894typedef struct {

Callers

nothing calls this directly

Calls 2

dictScanFunction · 0.85
dictUnsafeKeyOnlyMethod · 0.80

Tested by

no test coverage detected