use redis_module::{ key::RedisKey, redis_module, Context, KeysCursor, RedisResult, RedisString, RedisValue, }; fn scan_keys(ctx: &Context, _args: Vec) -> RedisResult { let cursor = KeysCursor::new(); let mut res = Vec::new(); let scan_callback = |_ctx: &Context, key_name: RedisString, _key: Option<&RedisKey>| { res.push(RedisValue::BulkRedisString(key_name)); }; while cursor.scan(ctx, &scan_callback) { // do nothing } Ok(RedisValue::Array(res)) } ////////////////////////////////////////////////////// redis_module! { name: "scan", version: 1, allocator: (redis_module::alloc::RedisAlloc, redis_module::alloc::RedisAlloc), data_types: [], commands: [ ["scan_keys", scan_keys, "readonly", 0, 0, 0], ], }