Skip to content

[Redis 8.10] Add support for the TS.READ time series command - #4642

Merged
atakavci merged 4 commits into
redis:masterfrom
atakavci:ali8.10/ts.read
Jul 27, 2026
Merged

atakavci merged 4 commits into
redis:masterfrom
atakavci:ali8.10/ts.read

Conversation

@atakavci

@atakavci atakavci commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the RedisTimeSeries TS.READ command to the Jedis client across all execution surfaces. TS.READ performs a non-blocking (or optionally blocking) forward read of samples whose timestamp is greater than or equal to a cursor, in ascending order, enabling cursor-based paging and tailing of a time series. Two overloads are exposed: a simple tsRead(key, timestamp) and a full tsRead(key, TSReadParams) supporting BLOCK and MAX_COUNT.

Key Decisions & Assumptions

  • New TSReadParams models the cursor plus optional BLOCK milliseconds min_count and MAX_COUNT max_count arguments. The cursor is either a non-negative literal (Unix ms) or one of the server-resolved sentinels - (earliest), + (latest existing sample), or $ (only samples added after the call).
  • The BLOCK group is all-or-nothing: requesting blocking always emits both milliseconds and min_count.
  • When BLOCK is present, the command is issued through blocking-command connection handling (args.blocking()); the simple overload never blocks.
  • Client-side validation rejects negative BLOCK milliseconds, non-positive min_count/max_count, and min_count > max_count, mirroring server constraints to fail fast.
  • The default cursor when none is set is - (earliest).

Behavioral / Conceptual Changes

  • tsRead is added to RedisTimeSeriesCommands / RedisTimeSeriesPipelineCommands and wired through CommandObjects, UnifiedJedis, and PipeliningBase.
  • Adds TS.READ protocol command and the BLOCK / MAX_COUNT keywords plus the $ cursor byte to TimeSeriesProtocol.
  • An empty list is a valid successful reply, including when a blocking call times out.

Testing

Adds TSReadParamsTest covering argument validation, blocking classification, wire-serialization order (BLOCK before MAX_COUNT), and equals/hashCode. Integration coverage is added to the time series command test base and cluster IT, plus pipeline and unified-jedis command tests exercising both overloads.

Notes

  • New public API is annotated @since 8.0.
  • TSReadParams.java is added to the formatter's included-sources list in pom.xml.

Note

Low Risk
Additive public API and protocol wiring following existing time-series and blocking-command patterns; no changes to auth or core connection logic beyond marking TS.READ as blocking when requested.

Overview
Adds RedisTimeSeries TS.READ to Jedis so clients can read samples with timestamp ≥ a cursor in ascending order, with optional paging and tailing.

New tsRead(key, timestamp) and tsRead(key, TSReadParams) are wired through command interfaces, CommandObjects, UnifiedJedis, and pipelines. TSReadParams builds the wire form (BLOCK, MAX_COUNT, cursor literals - / + / $) and validates argument constraints client-side. When BLOCK is set, CommandObjects marks the command blocking so connections use infinite-timeout read handling (same pattern as other blocking Redis commands). Protocol gains TS.READ, BLOCK, MAX_COUNT, and the $ cursor byte.

Integration tests cover non-blocking reads, MAX_COUNT paging, sentinels, blocking timeout/immediate return, and cross-connection wake; cluster IT disables the flaky blocking-wake case. Unit tests cover params serialization and mocked command routing.

Reviewed by Cursor Bugbot for commit 893eb97. Bugbot is set up for automated code reviews on this repo. Configure here.

@atakavci
atakavci requested a review from ggivo July 23, 2026 14:18
@atakavci atakavci self-assigned this Jul 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b53751443b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +201 to +214
/**
* {@code TS.READ key timestamp [BLOCK milliseconds min_count] [MAX_COUNT max_count]}
* <p>
* Returns up to {@code max_count} samples with timestamp greater than or equal to the cursor, in
* ascending timestamp order. With {@code BLOCK} the call waits until at least {@code min_count}
* qualifying samples exist or until the timeout elapses; without it the call returns immediately.
* An empty list is a successful reply, including when a blocking call times out.
*
* @param key the time series key
* @param readParams the cursor and optional {@code BLOCK} / {@code MAX_COUNT} arguments
* @return samples with timestamp {@code >=} the resolved cursor
* @since 8.0
*/
List<TSElement> tsRead(String key, TSReadParams readParams);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update docs for TS.READ public API

Because this adds the user-facing tsRead API and new TS.READ behavior, the maintained MkDocs pages under docs/ need a corresponding update; otherwise users relying on the project docs will not learn about the new command or its BLOCK/MAX_COUNT semantics even after upgrading.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for the RedisTimeSeries TS.READ command to Jedis’ TimeSeries module, exposing a cursor-based forward read API (with optional blocking and reply capping) and wiring it through the core execution surfaces (command objects, unified client, and pipelines), along with unit and integration coverage.

Changes:

  • Introduces TSReadParams to model TS.READ cursor + optional BLOCK/MAX_COUNT arguments (including blocking classification and validation).
  • Wires tsRead(...) through RedisTimeSeriesCommands / pipeline commands, CommandObjects, UnifiedJedis, and PipeliningBase, and extends TimeSeriesProtocol with TS.READ + new keywords/sentinel.
  • Adds unit tests for params serialization/validation and mocked + integration tests (with a targeted cluster override/disable for a known flush interaction).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/redis/clients/jedis/timeseries/TSReadParams.java New params object for TS.READ cursor + optional BLOCK/MAX_COUNT, including validation and blocking classification.
src/main/java/redis/clients/jedis/timeseries/TimeSeriesProtocol.java Adds TS.READ, $ sentinel bytes, and BLOCK/MAX_COUNT keywords to protocol enums/constants.
src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesCommands.java Adds new public tsRead overloads with @since and command javadocs.
src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesPipelineCommands.java Adds pipeline responses for tsRead overloads.
src/main/java/redis/clients/jedis/CommandObjects.java Implements tsRead command objects; applies args.blocking() when BLOCK is requested.
src/main/java/redis/clients/jedis/UnifiedJedis.java Exposes tsRead APIs on the unified client via CommandObjects.
src/main/java/redis/clients/jedis/PipeliningBase.java Exposes tsRead APIs on pipeline base via CommandObjects.
src/test/java/redis/clients/jedis/timeseries/TSReadParamsTest.java New unit test suite for TSReadParams validation, blocking classification, and wire serialization order.
src/test/java/redis/clients/jedis/mocked/unified/UnifiedJedisTimeSeriesCommandsTest.java Adds mocked unified-jedis tests for tsRead overloads.
src/test/java/redis/clients/jedis/mocked/pipeline/PipeliningBaseTimeSeriesCommandsTest.java Adds mocked pipeline tests for tsRead overloads.
src/test/java/redis/clients/jedis/commands/unified/timeseries/TimeSeriesCommandsTestBase.java Adds integration coverage for non-blocking reads, paging via MAX_COUNT, sentinels, blocking behavior, and error propagation.
src/test/java/redis/clients/jedis/commands/unified/cluster/timeseries/TimeSeriesClusterCommandsIT.java Disables the cross-client blocking wake test in cluster due to clean-cluster flush behavior.
pom.xml Ensures the new main-source file is included in formatter plugin inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ggivo ggivo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 893eb977c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@atakavci
atakavci merged commit 7d59fd0 into redis:master Jul 27, 2026
13 of 15 checks passed
@ggivo ggivo added this to the 8.0.0 milestone Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants