Skip to content

Conversation

@dfroger
Copy link

@dfroger dfroger commented Nov 4, 2025

BEFORE:

  • await pipe.expire() triggers ClusterPipeline.__await__
  • this triggers .initialize() which delete the pipeline commands

AFTER:

  • pipe.expire() in case of pipeline
  • await pipe.expire() in case of classic client

Here is a first try to fix #417 .

Tests and lint are ok. However I failed to run tests/integration/test_cluster_pipelining.py, cluster doesn't seems to start (test.log).

@jit-ci
Copy link

jit-ci bot commented Nov 4, 2025

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

BEFORE:
- await pipe.expire() triggers ClusterPipeline.__await__
- this triggers .initialize() which delete the pipeline commands

AFTER:
- pipe.expire() in case of pipeline
- await pipe.expire() in case of classic client
@dfroger dfroger marked this pull request as ready for review November 5, 2025 06:51
@dfroger dfroger marked this pull request as draft November 5, 2025 06:51
@dfroger dfroger marked this pull request as ready for review November 5, 2025 07:19
@abrookins abrookins requested a review from Copilot November 11, 2025 00:57
@abrookins
Copy link
Collaborator

Thanks @dfroger! We'll take a look ASAP.

Copilot finished reviewing on behalf of abrookins November 11, 2025 00:58
Copy link
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

This PR fixes an issue where setting TTL on async pipelines incorrectly triggered ClusterPipeline.__await__, which would prematurely initialize the pipeline and delete queued commands. The fix introduces a new _aexpire helper method that conditionally awaits based on whether the client is a pipeline or a regular async client.

Key Changes

  • Added _aexpire static method to handle TTL operations on async clients and pipelines
  • Updated awrite method to use the new _aexpire helper instead of directly awaiting pipe.expire()
  • Added comprehensive test coverage for TTL functionality across sync, async, and cluster configurations

Reviewed Changes

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

File Description
redisvl/index/storage.py Added _aexpire helper method and updated awrite to use it; fixed documentation type hints
tests/integration/test_search_index.py Added test for TTL functionality with sync client
tests/integration/test_cluster_pipelining.py Added test for TTL functionality with cluster client
tests/integration/test_async_search_index.py Added test for TTL functionality with async client
Comments suppressed due to low confidence (2)

redisvl/index/storage.py:700

  • The docstring parameter type 'AsyncClientOrPipeline' is inconsistent with the actual parameter type 'AsyncRedisClientOrPipeline' and inconsistent with the updated documentation in HashStorage._aset and HashStorage._aget. This should be changed to 'AsyncRedisClientOrPipeline' for consistency.
    async def _aset(client: AsyncRedisClientOrPipeline, key: str, obj: Dict[str, Any]):
        """Asynchronously set a JSON obj in Redis for the given key.

        Args:
            client (AsyncClientOrPipeline): The async Redis client or pipeline instance.

redisvl/index/storage.py:727

  • The docstring parameter type 'AsyncRedisClient' is inconsistent with the actual parameter type 'AsyncRedisClientOrPipeline' and inconsistent with the updated documentation in HashStorage._aset and HashStorage._aget. This should be changed to 'AsyncRedisClientOrPipeline' for consistency.
    async def _aget(client: AsyncRedisClientOrPipeline, key: str) -> Dict[str, Any]:
        """Asynchronously retrieve a JSON object from Redis for the given key.

        Args:
            client (AsyncRedisClient): The async Redis client or pipeline instance.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setting ttl delete the pipeline commands (cluster+async)

3 participants