Add meta_flags passthrough to write/delete/arithmetic and pipelined ops#70
Add meta_flags passthrough to write/delete/arithmetic and pipelined ops#70
Conversation
The meta protocol formatter previously supported a meta_flags: kwarg only
on meta_get, exposed publicly via Client#get and Client#gat. This extends
the same passthrough to the rest of the operations:
* Client#set / add / replace / cas (already had req_options; now plumbed
through to RequestFormatter.meta_set)
* Client#append / prepend (req_options added to public signature)
* Client#delete / delete_cas (req_options added)
* Client#incr / decr (req_options added as 5th positional arg)
* Client#get_multi / get_multi_cas (trailing **req_options kwargs)
* Client#set_multi (already had req_options; now flows to ms line)
* Client#delete_multi (req_options added)
For pipelined operations (get_multi, set_multi, delete_multi) the same
req_options hash is applied to every command in the pipeline. This is
documented as best-effort: callers are responsible for ensuring the
flags are appropriate for every key in the batch. Per-key flag overrides
are intentionally not supported.
Tests:
* RequestFormatter unit tests cover meta_flags on get/set/delete/arith.
* New integration suite test_meta_flags_passthrough.rb exercises every
public method against a real memcached, including a negative control
proving memcached rejects unrecognized flags.
| end | ||
| end | ||
|
|
||
| describe 'delete' do |
There was a problem hiding this comment.
We never delete in node-local cache, just let cache entry auto expired. For delete and delete_multi, what does the PROXY_FLAGS mean? Why do we need the p and l flags for deletions?
|
The |
|
Some things flagged when I checked this with claude... I think some of these are worth addressing with another quick pass. Concerns / suggestions
|
Summary
The meta protocol formatter previously supported a
meta_flags:kwarg only onmeta_get, exposed publicly viaClient#getandClient#gat. This extends the same passthrough to the rest of the operations:Client#set/add/replace/cas— already acceptedreq_options; now plumbed through toRequestFormatter.meta_setClient#append/prepend—req_optionsadded to the public signatureClient#delete/delete_cas—req_optionsaddedClient#incr/decr—req_optionsadded as 5th positional argClient#get_multi/get_multi_cas— trailing**req_optionskwargsClient#set_multi— already acceptedreq_options; now flows down to the inlinemsline inwrite_multi_storage_reqClient#delete_multi—req_optionsaddedPipelined behavior
For pipelined operations (
get_multi,set_multi,delete_multi) the samereq_optionshash is applied to every command in the pipeline. This is documented as best-effort: callers are responsible for ensuring the flags are appropriate for every key in the batch. Per-key flag overrides are intentionally not supported, since the obvious motivating use case — a single proxy/routing directive that should apply to every key in a batch — doesn't need them, and supporting them would significantly complicate the wire-building hot path.Public API
All changes are additive and backwards-compatible; existing callers are unaffected.
Implementation notes
RequestFormatter.meta_set/meta_delete/meta_arithmeticgain ameta_flags:kwarg mirroringmeta_get. Empty arrays are now treated as no flags everywhere (previouslymeta_getwithmeta_flags: []would emit a stray trailing space).read_multi_reqandwrite_multi_storage_reqbuild the wire format inline for performance, bypassing the formatter; a smallbuild_meta_flags_suffixhelper handles the splice.Protocol::Base#pipelined_getandProtocol::Meta#quiet_get_requestaccept areq_optionsarg so the multi-serverget_multipath also threads flags through.PipelinedGetter#processandPipelinedDeleter#processaccept a trailingreq_optionsarg, with YARD comments documenting the best-effort contract.Tests
test/protocol/meta/test_request_formatter.rb: +5 unit tests coveringmeta_flagsonmeta_get/meta_set/meta_delete/meta_arithmetic, plus the empty-array case.test/integration/test_meta_flags_passthrough.rb(new): 10 tests exercising every public method against a real memcached, plus a negative control that asserts an unrecognized flag letter raisesDalli::DalliError(locks in the protocol's flag-validation contract).Local results:
test_rack_session.rb, which is broken by an unrelated Ruby 4.0 /cgi/cookieissue): 345 runs, 109,964 assertions, 0 failures. The 10 errors observed are pre-existing toxiproxyECONNREFUSEDerrors unrelated to this change.