mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
Add memcached flush_all command.
Simplify reply code - remove the redundant class.
This commit is contained in:
parent
8054ed4f3a
commit
09fb05c0e1
10 changed files with 74 additions and 66 deletions
|
@ -185,7 +185,7 @@ void GenericFamily::Del(CmdArgList args, ConnectionContext* cntx) {
|
|||
if (del_cnt == 0) {
|
||||
mc_builder->SendNotFound();
|
||||
} else {
|
||||
mc_builder->SendDirect("DELETED\r\n");
|
||||
mc_builder->SendSimpleString("DELETED");
|
||||
}
|
||||
} else {
|
||||
(*cntx)->SendLong(del_cnt);
|
||||
|
|
|
@ -524,6 +524,9 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
|
|||
case MemcacheParser::GET:
|
||||
strcpy(cmd_name, "MGET");
|
||||
break;
|
||||
case MemcacheParser::FLUSHALL:
|
||||
strcpy(cmd_name, "FLUSHDB");
|
||||
break;
|
||||
case MemcacheParser::QUIT:
|
||||
strcpy(cmd_name, "QUIT");
|
||||
break;
|
||||
|
@ -531,7 +534,7 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
|
|||
server_family_.StatsMC(cmd.key, cntx);
|
||||
return;
|
||||
case MemcacheParser::VERSION:
|
||||
mc_builder->SendDirect(absl::StrCat("VERSION ", gflags::VersionString(), "\r\n"));
|
||||
mc_builder->SendSimpleString(absl::StrCat("VERSION ", gflags::VersionString()));
|
||||
return;
|
||||
default:
|
||||
mc_builder->SendClientError("bad command line format");
|
||||
|
@ -635,7 +638,7 @@ void Service::Quit(CmdArgList args, ConnectionContext* cntx) {
|
|||
(*cntx)->SendOk();
|
||||
using facade::SinkReplyBuilder;
|
||||
|
||||
SinkReplyBuilder* builder = static_cast<SinkReplyBuilder*>(cntx->reply_builder());
|
||||
SinkReplyBuilder* builder = cntx->reply_builder();
|
||||
builder->CloseConnection();
|
||||
}
|
||||
|
||||
|
@ -651,7 +654,7 @@ void Service::Multi(CmdArgList args, ConnectionContext* cntx) {
|
|||
void Service::CallFromScript(CmdArgList args, ObjectExplorer* reply, ConnectionContext* cntx) {
|
||||
DCHECK(cntx->transaction);
|
||||
InterpreterReplier replier(reply);
|
||||
facade::ReplyBuilderInterface* orig = cntx->Inject(&replier);
|
||||
facade::SinkReplyBuilder* orig = cntx->Inject(&replier);
|
||||
|
||||
DispatchCommand(std::move(args), cntx);
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ void ServerFamily::FlushDb(CmdArgList args, ConnectionContext* cntx) {
|
|||
},
|
||||
true);
|
||||
|
||||
(*cntx)->SendOk();
|
||||
cntx->reply_builder()->SendOk();
|
||||
}
|
||||
|
||||
void ServerFamily::FlushAll(CmdArgList args, ConnectionContext* cntx) {
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace {
|
|||
|
||||
using namespace std;
|
||||
using facade::Protocol;
|
||||
using facade::ReplyBuilderInterface;
|
||||
using facade::SinkReplyBuilder;
|
||||
|
||||
using CI = CommandId;
|
||||
DEFINE_VARZ(VarzQps, set_qps);
|
||||
|
@ -105,7 +105,7 @@ void StringFamily::Set(CmdArgList args, ConnectionContext* cntx) {
|
|||
sparams.memcache_flags = cntx->conn_state.memcache_flag;
|
||||
|
||||
int64_t int_arg;
|
||||
ReplyBuilderInterface* builder = cntx->reply_builder();
|
||||
SinkReplyBuilder* builder = cntx->reply_builder();
|
||||
|
||||
for (size_t i = 3; i < args.size(); ++i) {
|
||||
ToUpper(&args[i]);
|
||||
|
@ -342,7 +342,7 @@ void StringFamily::ExtendGeneric(CmdArgList args, bool prepend, ConnectionContex
|
|||
};
|
||||
|
||||
OpResult<bool> result = cntx->transaction->ScheduleSingleHopT(std::move(cb));
|
||||
ReplyBuilderInterface* builder = cntx->reply_builder();
|
||||
SinkReplyBuilder* builder = cntx->reply_builder();
|
||||
if (result.value_or(false)) {
|
||||
return builder->SendStored();
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ void StringFamily::MGet(CmdArgList args, ConnectionContext* cntx) {
|
|||
CHECK_EQ(OpStatus::OK, result);
|
||||
|
||||
// reorder the responses back according to the order of their corresponding keys.
|
||||
vector<ReplyBuilderInterface::OptResp> res(args.size() - 1);
|
||||
vector<SinkReplyBuilder::OptResp> res(args.size() - 1);
|
||||
|
||||
for (ShardId sid = 0; sid < shard_count; ++sid) {
|
||||
if (!transaction->IsActive(sid))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue