Check Redis server before hash field TTL#841
Open
sakshichitnis27 wants to merge 1 commit into
Open
Conversation
Author
|
Hi maintainers, |
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.
Fixes #829
Summary
Check the connected Redis server version before using hash field expiration commands. This prevents
HashModel.save()from callingHTTLon Redis versions older than 7.4.Added regression tests for supported and unsupported server versions.
Testing
pytest -q -n auto ./tests/ ./tests_sync/Fixes #829
Note
Medium Risk
Changes persistence paths for HashModel saves and field TTL APIs; behavior shifts on Redis < 7.4 (skips HTTL/HEXPIRE) but avoids runtime errors—worth verifying against production Redis versions.
Overview
Hash field expiration (
HTTL/HEXPIREonHashModel.save()and related APIs) is now gated on the connected Redis server version, not only redis-py ≥ 5.1.0.supports_hash_field_expiration(conn)is async, takes a connection, and returns false unlessINFO serverreports Redis 7.4+; failures from Redis or parsing are swallowed and treated as unsupported.HashModel.save()andexpire_field/field_ttl/persist_fieldawait that check withself.db()so older servers (e.g. 7.2) no longer hit unsupported commands during ordinary saves. Tests add parametrized server-version coverage and update the existing support probe to pass the fixture client.Reviewed by Cursor Bugbot for commit 35caf69. Bugbot is set up for automated code reviews on this repo. Configure here.