Repository navigation
Conversation
Reading or writing hundreds of keys one at a time costs one network round trip per key. These send the keys as pipelines of quiet gets and sets, and go through serverOp' so they keep the cluster's retry, timeout and failed-server handling. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
getFirstMultiandsetAllMulti, the many-key versions ofgetFirstandsetAll. Each sends its keys as a pipeline of quiet requests (GETKQ / SETQ) closed by a NOOP, so reading or writing many keys costs one round trip per 100 keys per server instead of one per key.They're for the higgs Orders live query, which now stores one memcached entry per order (restaumatic/restaumatic#13839). A client subscribing to a busy restaurant reads about 1000 entries.
Behaviour
getFirstMulti :: Cluster -> [Key] -> IO (Map Key (Value, Flags, Version))getFirstuses (orderServersForKey). A key that is missing on one server is asked from the next one.getFirst. The first exception is thrown when no server answered.setAllMulti :: Cluster -> [(Key, Value, Flags, Expiration)] -> IO [Either SomeException [(Key, Status)]]setAll.Both:
serverOp'(the cluster'sretryOp), so they keep the timeout, retry and failed-server handling.Supporting changes:
Cluster:getAliveServers,orderServersForKey(getServersForKeynow uses both),serverOp'.Socket:sendManywrites several requests in onesendAll.containersdependency for theMapresult.Known limitation, shared with
set:dzGenericResponseexpects an empty body, and memcached sends an error message in the body of a failed set. So a SETQ failure surfaces as a protocol error for that server, instead of a(key, status)entry.Test plan
Checked against a real memcached (
memcached-test:11211in the devcontainer), with a throwaway script:setAllMultiwith 250 pairs (3 chunks, half of them 20 KB values) returns[Right []].getFirstMultiwith those 250 keys plus 50 missing ones returns the 250 with correct values and flags.getFirstreturns the same value.127.0.0.1:1):setAllMultireturnsLeftfor it andRight []for the live one, andgetFirstMultifinds all 20 keys.getFirstMultithrows.-Wallwarnings in the changed modules.🤖 Generated with Claude Code