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
| 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. */ |
| 7682 | int 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 | |
| 7698 | typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata); |
| 7699 | typedef struct { |
nothing calls this directly
no test coverage detected