{{ message }}
Repository navigation
Add Redis TimeSeries write commands (2/6) - #3968
Merged
Merged
Conversation
a-TODO-rov
added this pull request to stack #3973
October 21, 2026 11:50
a-TODO-rov
removed this pull request from stack #3973
October 22, 2026 08:21
a-TODO-rov
added this pull request to stack #3977
October 22, 2026 08:21
Add the TS.ADD, TS.MADD, TS.INCRBY and TS.DECRBY command types and the ON_DUPLICATE and TIMESTAMP keywords.
Add the TS.ADD arguments with the per-call ON_DUPLICATE override, and the TS.INCRBY/TS.DECRBY arguments with TIMESTAMP, on the shared series options. The base serializer now places TIMESTAMP first and ON_DUPLICATE after DUPLICATE_POLICY, keeping LABELS last. Co-authored-by: HwangRock <peter9244@catholic.ac.kr>
TsMAddValue is one TS.MADD sample. of(key, timestamp, value) requires a non-negative timestamp; of(key, value) sends * so that the server clock sets the timestamp. Co-authored-by: HwangRock <peter9244@catholic.ac.kr>
TS.MADD replies with an array that holds an error element for each rejected sample. ErrorTolerantIntegerListOutput turns those elements into null and ErrorTolerantIntegerValueListOutput into Value.empty(), reading the reply to the end; an error reply instead of the array still fails the command. Co-authored-by: HwangRock <peter9244@catholic.ac.kr>
Add TS.ADD, TS.MADD, TS.INCRBY and TS.DECRBY to every API flavor. The TS.ADD overloads without a timestamp send * (server clock); their Javadoc warns that a long passed as the value compiles silently. TS.MADD returns null for each rejected sample (Value.empty() on the reactive API, List<Long?> on Kotlin), so the reactive tsMAdd and the builder method tsMAddValues are registered as known deviations. Co-authored-by: HwangRock <peter9244@catholic.ac.kr>
The advanced cluster API sends TS.MADD with keys in several slots as one command per slot, in parallel, and puts the results back in the caller's order. Samples are partitioned by position, because one key can appear several times. A slot whose command fails fails the whole call, as with MGET. The split is not atomic across slots.
Add the writes section to the TimeSeries user guide: TS.ADD with and without a timestamp and the long-to-double pitfall, IGNORE (only with duplicate policy LAST), TS.MADD partial failure and the per-slot split in Redis Cluster, and TS.INCRBY/TS.DECRBY.
The Java long-to-double warning does not apply in Kotlin, which does not widen a Long to a Double. Drop it from tsAdd(key, value) and tsAdd(key, value, args), and name the overloads that set the timestamp as tsAdd(key, timestamp, value) and tsAdd(key, timestamp, value, args).
The slot split happens in the Redis Cluster API only. Name it in the tsMAdd documentation of all six flavors, and state in the class documentation of both node-selection interfaces that tsMAdd runs unchanged on every selected node, so its keys must hash to slots that node serves.
a-TODO-rov
force-pushed
the
ts/p2-writes
branch
from
October 22, 2026 08:22
019ead9 to
79296ae
Compare
4 tasks done
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 TS.ADD, TS.MADD, TS.INCRBY and TS.DECRBY to every API flavor, including the series options these commands accept: ON_DUPLICATE, IGNORE and LABELS last.
Key Decisions & Assumptions
tsAddwithout a timestamp sends*, so the server clock sets it. The Java Javadoc warns thattsAdd(key, long)would silently becometsAdd(key, double).nullelement and the other samples are still stored. The parsing is done by a newErrorTolerantIntegerListOutput, following the existingErrorTolerantBooleanListOutput(BF.MADD). The reactive API returnsValue.empty()and Kotlin returnsList<Long?>.mgetis. The result keeps the caller's order. The split is not atomic across slots, which is documented. Node selection runs the command unchanged on each selected node.Behavioral / Conceptual Changes
IGNORE only takes effect with the duplicate policy LAST. This is server behavior, documented in the Javadoc and the user guide.
Testing
Notes
Stacked on
ts/p1-lifecycle(PR 1/6); review only this PR's commits.Inside MULTI/EXEC: a partly rejected TS.MADD gives
nullelements, like outside a transaction. This relies on fix(output): forward ByteBuffer error to queued command output (#3960) #3963 (already merged); the test is in P4.Credit: parts are based on Add RedisTimeSeries (TS.*) support #3852 by @HwangRock (
Co-authored-byon those commits).You have read the contribution guidelines.
You have created a feature request first to discuss your contribution intent: Add support for Redis Timeseries #2716
You applied code formatting rules using the
mvn formatter:formattarget.You submit test cases (unit or integration tests) that back your changes.
Note
Medium Risk
New public API surface and cluster slot-splitting for
tsMAddcan leave partial writes if one slot fails; MADD partial-failure parsing is protocol-sensitive but heavily tested.Overview
Adds Redis TimeSeries write commands across sync, async, reactive, Kotlin coroutines, and cluster APIs:
tsAdd(explicit timestamp or server*),tsMAdd,tsIncrBy, andtsDecrBy, withTsAddArgs/TsIncrByArgsfor series-creation options, per-callON_DUPLICATE,IGNORE, and labels.TS.MADD uses new error-tolerant list outputs so per-sample Redis errors become
null(orValue.empty()/List<Long?>) without failing the whole command. On Redis Cluster, multi-slottsMAddis split per hash slot viaTimeSeriesSlotPartition, results are merged in caller order, and cross-slot execution is documented as non-atomic.The user guide gains a Writes section (including the
tsAdd(key, long)footgun). Integration and unit tests cover encoding, duplicate/IGNORE behavior, cluster splits, and RESP framing.Reviewed by Cursor Bugbot for commit 019ead9. Bugbot is set up for automated code reviews on this repo. Configure here.