mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 18:40:38 +00:00
memcache: support 'noreply' on 'set' and 'delete'
This commit is contained in:
@@ -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; };
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user