Repository navigation
feat: add putIfAbsent/replace/containsKey conditional operations - #5
Merged
Merged
Conversation
Completes Step 10 with the three remaining conditional operations: - putIfAbsent (0x05/0x06): store only if the key is absent - replace (0x07/0x08): store only if the key is present - containsKey (0x0F/0x10): key-existence test putIfAbsent/replace reuse PUT's request layout (key + expiration byte + value) and return future<optional<EntryWithMetadata>> — the previous / replaced entry when previousValue (FORCE_RETURN_VALUE) is set, nullopt otherwise. Parsers drain the *_WITH_PREVIOUS (0x03/0x04) body defensively. containsKey is a key-only request returning future<bool> from the status (no response body). Cross-checked against Java PutIfAbsentOperation / ReplaceOperation / ContainsKeyOperation and hotrod40.ksy (put_if_absent/replace map to put_request/put_response; contains_key maps to key_request with a status-only response). Tests: 11 unit + 12 integration, all passing. Unit 176/176, integration 75/75 across 14 suites. Clean Release build with -Werror -Wall -Wextra. Co-Authored-By: Claude Opus 4.8 <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
Completes Step 10 with the three remaining conditional operations:
putIfAbsentfuture<optional<EntryWithMetadata>>replace(only if present)future<optional<EntryWithMetadata>>containsKeyfuture<bool>putIfAbsent/replacereuse PUT's request layout (key + expiration byte + value). They return the previous / replaced entry whenpreviousValue(FORCE_RETURN_VALUE) is set,nulloptotherwise; parsers drain the*_WITH_PREVIOUS(0x03/0x04) body defensively so the shared read loop stays byte-aligned once that flag is wired up.containsKeyis a key-only request returning a bool from the response status (no response body).Cross-check
Verified against all three legs:
put()/get().PutIfAbsentOperation,ReplaceOperation,ContainsKeyOperation(all extend the same key/value/key operation bases).put_if_absent/replacedispatch toput_request/put_response;contains_keydispatches tokey_requestwith a status-only response.Tests
PutIfAbsentTest,ReplaceTest,ContainsKeyTest) — request encoding + opcode constants.PutIfAbsent,Replace,ContainsKey) — stored/not-stored/previous-value semantics against Docker Infinispan.-Werror -Wall -Wextra.🤖 Generated with Claude Code