feat: support deletions with meta protocol (#4398)

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2025-01-03 15:06:24 +02:00 committed by GitHub
parent 6e9409c65c
commit 4f09fe036c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 3 deletions

View file

@ -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);
@ -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);
@ -432,7 +436,6 @@ void RedisReplyBuilder::SendLabeledScoredArray(std::string_view arr_label, Score
SendBulkString(str);
SendDouble(score);
}
}
void RedisReplyBuilder::SendStored() {

View file

@ -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);

View file

@ -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);

View file

@ -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