diff --git a/apps/memcache/ascii.rl b/apps/memcache/ascii.rl index dfe073b8af..41a0d755e4 100644 --- a/apps/memcache/ascii.rl +++ b/apps/memcache/ascii.rl @@ -45,9 +45,9 @@ blob := any+ >start_blob $advance_blob; maybe_noreply = (sp "noreply" @{ _noreply = true; })? >{ _noreply = false; }; maybe_expiration = (sp expiration)? >{ _expiration = 0; }; -set = "set" sp key sp flags sp expiration sp size (crlf @{ fcall blob; } ) crlf @{ _state = state::cmd_set; }; +set = "set" sp key sp flags sp expiration sp size maybe_noreply (crlf @{ fcall blob; } ) crlf @{ _state = state::cmd_set; }; get = "get" (sp key %{ _keys.push_back(std::move(_key)); })+ crlf @{ _state = state::cmd_get; }; -delete = "delete" sp key crlf @{ _state = state::cmd_delete; }; +delete = "delete" sp key maybe_noreply crlf @{ _state = state::cmd_delete; }; flush = "flush_all" maybe_expiration maybe_noreply crlf @{ _state = state::cmd_flush_all; }; version = "version" crlf @{ _state = state::cmd_version; }; main := (set | get | delete | flush | version) >eof{ _state = state::eof; }; diff --git a/apps/memcache/memcache.cc b/apps/memcache/memcache.cc index 1a23a0fe7f..f76af62713 100644 --- a/apps/memcache/memcache.cc +++ b/apps/memcache/memcache.cc @@ -250,6 +250,9 @@ public: case memcache_ascii_parser::state::cmd_set: _cache.set(std::move(_parser._key), item_data{std::move(_parser._blob), _parser._flags, seconds_to_time_point(_parser._expiration)}); + if (_parser._noreply) { + return make_ready_future<>(); + } return out.write(msg_stored); case memcache_ascii_parser::state::cmd_get: @@ -284,10 +287,13 @@ public: } case memcache_ascii_parser::state::cmd_delete: - if (_cache.remove(_parser._key)) { - return out.write(msg_deleted); + { + auto removed = _cache.remove(_parser._key); + if (_parser._noreply) { + return make_ready_future<>(); } - return out.write(msg_not_found); + return out.write(removed ? msg_deleted : msg_not_found); + } case memcache_ascii_parser::state::cmd_flush_all: if (_parser._expiration) {