Update redis backend support - #26
Open
Nagico wants to merge 10 commits into
Open
Conversation
added 10 commits
December 27, 2022 00:25
epicserve
requested changes
Jan 28, 2023
epicserve
left a comment
Owner
There was a problem hiding this comment.
Thank you for your contribution. I finally had some time to review this. I've added a couple of comments in the code.
| architecture: x64 | ||
| - run: | | ||
| pip install pytest coverage pytest-cov ${{ matrix.django-version }} | ||
| pip install pytest coverage pytest-cov mock ${{ matrix.django-version }} |
Owner
There was a problem hiding this comment.
You don't need to install mock; you can use unittest.mock.
| DJANGO_REDIS_CACHE_BACKEND = 'redis_cache.RedisCache' | ||
| DJANGO_REDIS_BACKEND = 'django_redis.cache.RedisCache' if VERSION[0] < 4 else BUILTIN_DJANGO_BACKEND | ||
|
|
||
| DEFAULT_REDIS_BACKEND = DJANGO_REDIS_BACKEND if VERSION[0] < 4 else BUILTIN_DJANGO_BACKEND |
Owner
There was a problem hiding this comment.
It might be good to set VERSION[0] < 4 to a constant like:
IS_DJANGO_VERSION_GTE_4 = VERSION[0] >= 4Then when parse() is called, add something like the following inside the function:
if IS_DJANGO_VERSION_GTE_4 is True and url.scheme in ('redis', 'rediss', 'hiredis'):
warnings.warn(
(
"django-cache-url is no longer needed since Django version 4 or newer has a native Redids backend built in."
"See the Django documentation (https://docs.djangoproject.com/en/4.0/topics/cache/#redis) for details."
),
DeprecationWarning
)
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.
feat:
native django redis-py,django-redisbackend based on url connection: addUSERfield for authenticationnative django redis-py,django-redisbackend based on socket connection: addUSERandPASSWORDfield for authenticationdjango-redis-cachebackend: throw exception whenUSERfield is settest_redis.pyfile: replace pytest.mark.skipif with pytest.fixture and mock, addconftest.pyfile which providesdjango_cache_url_dj3anddjango_cache_url_dj4, two mocked modules as fixtures, for each test function.fix:
native django redis-pybackend: covert the keys in the OPTIONS to lower casedocs:
readme.rstfile: updateredis,rediss,hiredisusage about authentication and native redis backendMore information about available schemes of different redis backends