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