rust-memcache icon indicating copy to clipboard operation
rust-memcache copied to clipboard

Support multi-key operations

Open jonhoo opened this issue 6 years ago • 6 comments

In memcached you can pipeline sending multiple operations to use the network more efficiently. We already have Client::gets, but set, delete, and increment can also be pipelined this way. For high-performance applications, doing this kind of request batching is essential, so it'd be awesome to see support for these added to this crate! The old memcached-rs crate had support for this in the MultiOperation trait, and the implementation is pretty straightforward (and similar to gets).

jonhoo avatar Mar 06 '19 16:03 jonhoo

Got, I'll try to implemented this on weekend.

aisk avatar Mar 07 '19 07:03 aisk

I have a question, looks like the ascii protocol does not support multiple operations like sets, and since this crate support both ascii and binary protocol, should we just return an error, or just doing multiple requests to emulate the multiple actions if current client is using ascii protocol?

aisk avatar Mar 07 '19 07:03 aisk

Hmm, I thought the text protocol also supported pipelining requests just fine? Specifically, you can send off multiple requests in rapid succession, and then only wait for them after they've all been sent, no?

jonhoo avatar Mar 07 '19 14:03 jonhoo

Pipelining works with ASCII with some caveats; if there's an error in the protocol (bad key/something) you end up with a protocol desync and the rest of the commands sent in the pipeline could error. This is worse with if the 'noreply' option is used since that suppresses most errors.

It does work differently than 'get', which has a specific mechanism for pipelining: get key key key key.

dormando avatar Jul 12 '19 21:07 dormando

@dormando I think I was trying to implement deletes function and find the ascii protocol can not support it well. I think I'll try to simulate it using multi operations if people trying using multi key operation under ascii protocol as fallback.

aisk avatar Jul 13 '19 04:07 aisk

See PR #110 :-)

hathawsh avatar Feb 09 '20 09:02 hathawsh