Skip to content

Conversation

@wloggains-mmllc
Copy link

Problem
There are some situations where the _client in RedisCache is not instantiated when the close() method is called. We have ran into this specifically with django.core.cache.CacheHandler.close_caches(). While it does not cause an error, it is an inefficiency.

Solution
This pull request makes an update to django_redis/cache.py::RedisCache.close() to prevent unnecessary initialization of the _client.

The close method now checks if _client is not None before attempting to close the client.

I have also added a test.

@kingbuzzman
Copy link

@WisdomPill hey is there anything else you'd like to see?

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.

2 participants