Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:Expire method fails when using DEFAULT_TIMEOUT #726

Merged
merged 7 commits into from
Feb 17, 2024

Conversation

sauravsharma1998
Copy link

@sauravsharma1998 sauravsharma1998 commented Feb 16, 2024

closes #724

Copy link
Member

@WisdomPill WisdomPill left a comment

Choose a reason for hiding this comment

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

we need a test and changelog

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (81ec264) 61.6% compared to head (8bf4390) 61.5%.
Report is 4 commits behind head on master.

Files Patch % Lines
tests/test_backend.py 11.2% 8 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #726     +/-   ##
========================================
- Coverage    61.6%   61.5%   -0.1%     
========================================
  Files          43      43             
  Lines        2773    2786     +13     
  Branches      161     161             
========================================
+ Hits         1708    1713      +5     
- Misses       1052    1060      +8     
  Partials       13      13             
Flag Coverage Δ
mypy 38.2% <23.1%> (-<0.1%) ⬇️
tests 89.4% <100.0%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sauravsharma1998
Copy link
Author

@WisdomPill Whenever it's convenient for you, could you please take a moment to review and approve the workflow? Your approval would be greatly appreciated. Thank you!

Copy link
Member

@WisdomPill WisdomPill left a comment

Choose a reason for hiding this comment

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

we're getting there... could you do the same for pexpire as well?

Comment on lines 302 to 304
# timeout could be of type int|timedelta
# if timeout is DEFAULT_TIMEOUT or None then
# use self._backend.default_timeout(django default cache timeout)
Copy link
Member

Choose a reason for hiding this comment

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

can you please remove this?

@@ -0,0 +1,3 @@
Fix for Issue 724(expire method fails when using DEFAULT_TIMEOUT)

https://github.com/jazzband/django-redis/issues/724
Copy link
Member

Choose a reason for hiding this comment

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

no need to point out the issue just write an explanation

Comment on lines 306 to 307
# for some strange reason mypy complains,
# saying that timeout type is float | timedelta
Copy link
Member

Choose a reason for hiding this comment

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

please remove this comment

@@ -606,6 +607,10 @@ def test_expire(self, cache: RedisCache):
assert pytest.approx(ttl) == 20
assert cache.expire("not-existent-key", 20) is False

def test_expire_with_default_timeout(self, cache: RedisCache):
cache.set("foo", "bar", timeout=None)
assert cache.expire("foo", DEFAULT_TIMEOUT) is True
Copy link
Member

Choose a reason for hiding this comment

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

can you try to expire a non existing key as well?

@WisdomPill WisdomPill changed the title Fix:Expire method fails when using DEFAULT_TIMEOUT #724 Fix:Expire method fails when using DEFAULT_TIMEOUT Feb 16, 2024
@sauravsharma1998
Copy link
Author

@WisdomPill Your valuable input has been carefully integrated. Whenever you have a moment, could you kindly review and approve the workflow? Your cooperation is sincerely appreciated. Thank you!

Copy link
Member

@WisdomPill WisdomPill left a comment

Choose a reason for hiding this comment

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

LGTM!

just one small thing to remove and we're good

django_redis/client/default.py Outdated Show resolved Hide resolved
@@ -315,6 +318,9 @@ def pexpire(
version: Optional[int] = None,
client: Optional[Redis] = None,
) -> bool:
if (timeout is DEFAULT_TIMEOUT) or (timeout is None):
Copy link
Member

Choose a reason for hiding this comment

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

I would let people set None as timeout and get the exception from the client so that they notice they made a mistake instead of getting a seemingly random expiry time

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your feedback @WisdomPill!
Changes are done. Please approve the workflow.

@WisdomPill WisdomPill merged commit 5506eee into jazzband:master Feb 17, 2024
17 of 20 checks passed
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.

Expire method fails when using DEFAULT_TIMEOUT
2 participants