Redis backend connection fix #153
Merged
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.
Sorry again about my messing about with unrelated commits, this is a copy of the previous PR with the correct commits this time!
Hi!
As mentioned yesterday in #149, I found some problems with cachecontrol attempting to close the connection to redis when .close is called on the cache adapter, causing issues because the
Redis
object doesn't have a disconnect method.I'm not an expert on redis, but as far as I can tell py-redis uses connection pooling by default, making it unnecessary to explicitly close connections (source: http://stackoverflow.com/questions/24875806/redis-in-python-how-do-you-close-the-connection)
I've coded up a quick fix that simply doesn't do anything when closing a redis cache, which I think is the correct behaviour. There might be cases where a user manages to instantiate redis without a connection pool, in which case closing the connection might be necessary, but I don't even know how to do that, so I'm hoping we can shelve that potential problem for now.
For reference, here's a quick example of code I've been using that caused problems for me with the original behaviour: