-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update redis backend support #26
base: master
Are you sure you want to change the base?
Conversation
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.
Thank you for your contribution. I finally had some time to review this. I've added a couple of comments in the code.
@@ -55,6 +55,6 @@ jobs: | |||
python-version: ${{ matrix.python-version }} | |||
architecture: x64 | |||
- run: | | |||
pip install pytest coverage pytest-cov ${{ matrix.django-version }} | |||
pip install pytest coverage pytest-cov mock ${{ matrix.django-version }} |
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.
You don't need to install mock; you can use unittest.mock.
DJANGO_REDIS_CACHE_LIB_KEY = 'redis-cache' | ||
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 |
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.
It might be good to set VERSION[0] < 4
to a constant like:
IS_DJANGO_VERSION_GTE_4 = VERSION[0] >= 4
Then 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
)
feat:
native django redis-py
,django-redis
backend based on url connection: addUSER
field for authenticationnative django redis-py
,django-redis
backend based on socket connection: addUSER
andPASSWORD
field for authenticationdjango-redis-cache
backend: throw exception whenUSER
field is settest_redis.py
file: replace pytest.mark.skipif with pytest.fixture and mock, addconftest.py
file which providesdjango_cache_url_dj3
anddjango_cache_url_dj4
, two mocked modules as fixtures, for each test function.fix:
native django redis-py
backend: covert the keys in the OPTIONS to lower casedocs:
readme.rst
file: updateredis
,rediss
,hiredis
usage about authentication and native redis backendMore information about available schemes of different redis backends