@@ -161,9 +161,42 @@ class CommandCFExists : public Commander {
161161 }
162162};
163163
164- // Register the CF.RESERVE, CF.ADD, and CF.EXISTS commands
164+ class CommandCFMExists : public Commander {
165+ public:
166+ Status Parse (const std::vector<std::string> &args) override {
167+ // CF.MEXISTS key item [item ...]
168+ if (args.size () < 3 ) {
169+ return {Status::RedisParseErr, " wrong number of arguments" };
170+ }
171+ return Commander::Parse (args);
172+ }
173+
174+ Status Execute (engine::Context &ctx, Server *srv, Connection *conn, std::string *output) override {
175+ redis::CuckooChain cuckoo_db (srv->storage , conn->GetNamespace ());
176+ std::vector<std::string> items (args_.begin () + 2 , args_.end ());
177+ std::vector<bool > exists;
178+ auto s = cuckoo_db.MExists (ctx, args_[1 ], items, &exists);
179+
180+ if (!s.ok ()) {
181+ if (s.IsNotFound ()) {
182+ exists.assign (items.size (), false );
183+ } else {
184+ return {Status::RedisExecErr, " failed to check items existence in cuckoo filter" };
185+ }
186+ }
187+
188+ *output = redis::MultiLen (exists.size ());
189+ for (bool exist : exists) {
190+ output->append (redis::Integer (exist ? 1 : 0 ));
191+ }
192+ return Status::OK ();
193+ }
194+ };
195+
196+ // Register the CF.RESERVE, CF.ADD, CF.EXISTS, and CF.MEXISTS commands
165197REDIS_REGISTER_COMMANDS (CuckooFilter, MakeCmdAttr<CommandCFReserve>(" cf.reserve" , -3 , " write" , 1 , 1 , 1 ),
166198 MakeCmdAttr<CommandCFAdd>(" cf.add" , 3 , " write" , 1 , 1 , 1 ),
167- MakeCmdAttr<CommandCFExists>(" cf.exists" , 3 , " read-only" , 1 , 1 , 1 ))
199+ MakeCmdAttr<CommandCFExists>(" cf.exists" , 3 , " read-only" , 1 , 1 , 1 ),
200+ MakeCmdAttr<CommandCFMExists>(" cf.mexists" , -3 , " read-only" , 1 , 1 , 1 ))
168201
169202} // namespace redis
0 commit comments