-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b775d0c
Fix:Expire method fails when using DEFAULT_TIMEOUT #724
f391938
Testcase and changelog added for issue #724
740520a
Changelog file renamed
9a38b1c
Fix:mypy errors
6285275
Fix for DEFAULT_TIMEOUT for pexpire, unwanted comments removed and te…
23b1b68
Improvement: None removed for timeout
8bf4390
Improvement: None removed for timeout
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix for Issue 724(expire method fails when using DEFAULT_TIMEOUT) | ||
|
||
https://github.com/jazzband/django-redis/issues/724 | ||
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,13 @@ def expire( | |
version: Optional[int] = None, | ||
client: Optional[Redis] = None, | ||
) -> bool: | ||
# timeout could be of type int|timedelta | ||
# if timeout is DEFAULT_TIMEOUT or None then | ||
# use self._backend.default_timeout(django default cache timeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove this? |
||
|
||
if (timeout is DEFAULT_TIMEOUT) or (timeout is None): | ||
sauravsharma1998 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
timeout = self._backend.default_timeout | ||
|
||
if client is None: | ||
client = self.get_client(write=True) | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import pytest | ||
from django.core.cache import caches | ||
from django.core.cache.backends.base import DEFAULT_TIMEOUT | ||
from django.test import override_settings | ||
from pytest_django.fixtures import SettingsWrapper | ||
from pytest_mock import MockerFixture | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you try to expire a non existing key as well? |
||
|
||
def test_pexpire(self, cache: RedisCache): | ||
cache.set("foo", "bar", timeout=None) | ||
assert cache.pexpire("foo", 20500) is True | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
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