Skip to content

Adding support for new INCREX command#4067

Open
petyaslavova wants to merge 6 commits into
masterfrom
ps_add_increx_support
Open

Adding support for new INCREX command#4067
petyaslavova wants to merge 6 commits into
masterfrom
ps_add_increx_support

Conversation

@petyaslavova
Copy link
Copy Markdown
Collaborator

@petyaslavova petyaslavova commented May 15, 2026

Description of change

Add support for the new INCREX command. The command is exposed as increx(...) on the core Redis command API with sync and async overloads, matching the existing redis-py command style.
The implementation supports default increment behavior, BYINT, BYFLOAT, lower and upper bounds, OVERFLOW modes, expiration options, PERSIST, and ENX.

The new API builds command arguments explicitly and validates mutually exclusive options before dispatching to Redis. Expiration options use at_most_one_value_set with is not None checks so values like ex=0 and px=0 are treated as provided arguments, rather than being skipped due to Python truthiness. The same validation fix was applied to related command helpers that use EX, PX, EXAT, PXAT, PERSIST, or KEEPTTL.

Tests were added for sync and async clients. INCREX coverage includes default increment, BYINT, BYFLOAT, saturating overflow behavior, rejected overflow preserving the existing value, expiration with ENX, and invalid option combinations.

Additional regression tests cover zero-valued expiration arguments for GETEX, MSETEX, SET, INCREX, HGETEX, and HSETEX, with each test placed near the command it exercises. A SET conditional validation test was also added to ensure empty conditional values like ifeq=b"" still count as provided when checking mutual exclusivity.


Note

Medium Risk
Adds a new Redis command surface (increx) and changes argument validation for multiple TTL/conditional options; behavior changes could affect callers that previously relied on falsy values (e.g., ex=0) being ignored. Test changes reduce flakiness but touch concurrency timing in cluster initialization tests.

Overview
Adds a new core client command increx(...) (sync/async overloads) to support Redis INCREX, including BYINT/BYFLOAT, bounds + OVERFLOW, expiration flags (EX/PX/EXAT/PXAT), PERSIST, and ENX, with explicit option validation before dispatch.

Fixes several commands (getex, msetex, set, hgetex, hsetex, plus increx) to validate mutually-exclusive expiry/conditional options using is not None checks so zero/empty values (e.g., ex=0, ifeq=b"") are not silently ignored; adds regression tests for these cases.

Stabilizes flaky BGSAVE tests by polling INFO persistence instead of sleeping, and makes a cluster initialize() vs move_slot() concurrency test deterministic via synchronization events/timeouts; CI is also updated to test Redis 8.8 against 8.8-rc1.

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

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 15, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new increx command to the core Redis command API (sync + async overloads) supporting BYINT/BYFLOAT, LBOUND/UBOUND, OVERFLOW, expiration options, PERSIST, and ENX. Also tightens mutual-exclusivity checks in getex, msetex, set, hgetex, and hsetex so zero-valued expiration/empty conditional arguments are treated as provided. Updates the CI 8.8 matrix to use the 8.8-rc1 Redis image.

Changes:

  • New increx API with client-side validation for mutually exclusive options, overflow values, and enx requiring an expiration.
  • Replaced truthiness-based at_most_one_value_set invocations with explicit is not None checks across several existing commands.
  • Added sync and async tests for INCREX behavior and regression tests for zero-valued expiry / empty conditional arguments; updated 8.8 Redis image tag in integration workflow.

Reviewed changes

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

File Description
redis/commands/core.py Adds increx sync/async overloads and implementation; updates mutual-exclusivity checks in getex, msetex, set, hgetex, hsetex.
tests/test_commands.py Adds sync INCREX tests and zero-value/empty-value regression tests for GETEX/MSETEX/SET/HGETEX/HSETEX.
tests/test_asyncio/test_commands.py Mirrors async tests for the above.
.github/workflows/integration.yaml Switches the 8.8 Redis version mapping to 8.8-rc1.

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

Comment thread redis/commands/core.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 22ac22f. Configure here.

Comment thread tests/test_cluster.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants