feat(time-series): add TS.READ cursor read command#3322
Open
nkaradzhov wants to merge 2 commits into
Open
Conversation
Add client support for the RedisTimeSeries TS.READ command (since 8.10.0), a read-only, single-key cursor reader that returns a batch of (timestamp, value) samples with timestamp at or after a cursor, in ascending order. Wire shape: TS.READ key timestamp [BLOCK milliseconds min_count] [MAX_COUNT max_count]. The timestamp cursor accepts a non-negative integer or one of the sentinels -, +, $ (exposed as TS_READ_TIMESTAMP). The BLOCK group is all-or-nothing; minCount is optional in the typed API (defaults to 1) but always emitted on the wire. Replies reuse the existing TS.RANGE sample parser for RESP2 and RESP3. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- re-export TS_READ_TIMESTAMP/TsReadTimestamp/TsReadOptions from
package entry; JSDoc {@link} target was unreachable for users
- narrow TsReadTimestamp to number | Date | sentinels: bare string
in Timestamp absorbed the literals, any string compiled
- add integration tests for LATEST/NEW sentinels and BLOCK
(synchronous path + timeout empty flush)
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.
This pull request adds client support for the RedisTimeSeries
TS.READcommand (since 8.10.0), a read-only, single-key cursor reader that returns a batch of(timestamp, value)samples with timestamp at or after a cursor, in ascending order. With the optionalBLOCKgroup it waits until at leastminCountqualifying samples exist or a timeout elapses, enabling continuous batch consumption of historical and newly appended samples without pollingTS.RANGE.Wire shape:
TS.READ key timestamp [BLOCK milliseconds min_count] [MAX_COUNT max_count]. Thetimestampcursor accepts a non-negative integer or one of the sentinels-/+/$(exposed asTS_READ_TIMESTAMP). TheBLOCKgroup is all-or-nothing;minCountmay be omitted in the typed API (defaults to1) but is always emitted on the wire. Replies reuse the existingTS.RANGEsample parser (RESP2/RESP3).Behavior considerations:
dont_cache); cluster clients route by the key's hash slot.BLPOP); the command object carries no blocking flag. Callers opting intoBLOCKshould run it on an isolated connection.🤖 Generated with Claude Code
Note
Low Risk
Additive read-only command following existing TS command patterns; blocking behavior is opt-in and documented like other blocking Redis commands.
Overview
Adds client support for RedisTimeSeries
TS.READ(Redis 8.10+): a read-only, single-key cursor read that returns ascending(timestamp, value)batches from an inclusive cursor, with optionalBLOCK/MAX_COUNT.The new command wires
TS.READ key timestamp [BLOCK ms min_count] [MAX_COUNT n], exposes cursor sentinels asTS_READ_TIMESTAMP(-,+,$), defaultsminCountto1whenBLOCKis set, and parses replies via the existing range sample transformers.client.ts.read/READare registered on the time-series module andTsReadTimestamp,TsReadOptions, andTS_READ_TIMESTAMPare exported from the package entry.Tests cover argument encoding and integration behavior (including sentinels,
MAX_COUNT, missing keys, andBLOCKsync/timeout cases) behindminimumDockerVersion: [8, 10].Reviewed by Cursor Bugbot for commit dea3295. Bugbot is set up for automated code reviews on this repo. Configure here.