Skip to content

Commit

Permalink
feat: support deletions with meta protocol (#4398)
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
  • Loading branch information
romange authored Jan 3, 2025
1 parent 6e9409c commit 4f09fe0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/facade/reply_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ void MCReplyBuilder::SendMiss() {
SendSimpleString("EN");
}

void MCReplyBuilder::SendDeleted() {
SendSimpleString(flag_.meta ? "HD" : "DELETED");
}

void MCReplyBuilder::SendRaw(std::string_view str) {
ReplyScope scope(this);
WriteRef(str);
Expand Down Expand Up @@ -422,7 +426,7 @@ void RedisReplyBuilder::SendScoredArray(ScoredArray arr, bool with_scores) {

void RedisReplyBuilder::SendLabeledScoredArray(std::string_view arr_label, ScoredArray arr) {
ReplyScope scope(this);

StartArray(2);

SendBulkString(arr_label);
Expand All @@ -432,7 +436,6 @@ void RedisReplyBuilder::SendLabeledScoredArray(std::string_view arr_label, Score
SendBulkString(str);
SendDouble(score);
}

}

void RedisReplyBuilder::SendStored() {
Expand Down
1 change: 1 addition & 0 deletions src/facade/reply_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class MCReplyBuilder : public SinkReplyBuilder {
void SendClientError(std::string_view str);
void SendNotFound();
void SendMiss();
void SendDeleted();
void SendGetEnd();

void SendValue(std::string_view key, std::string_view value, uint64_t mc_ver, uint32_t mc_flag);
Expand Down
2 changes: 1 addition & 1 deletion src/server/generic_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ void DeleteGeneric(CmdArgList args, const CommandContext& cmd_cntx) {
if (del_cnt == 0) {
mc_builder->SendNotFound();
} else {
mc_builder->SendSimpleString("DELETED");
mc_builder->SendDeleted();
}
} else {
builder->SendLong(del_cnt);
Expand Down
2 changes: 2 additions & 0 deletions tests/dragonfly/memcache_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ def test_basic(df_server: DflyInstance):
response = pool.meta_get(Key("key1"), flags=request_flags)
assert isinstance(response, Success)
assert pool.get("key2") is None
assert pool.delete("key1")
assert pool.delete("key1") is False

0 comments on commit 4f09fe0

Please sign in to comment.