At the moment, the redis backend creates a new StrictRedis-object for every redis request. This essentially nulls out the built-in connection pooling in the StrictRedis-class. See https://github.com/andymccurdy/redis-py/blob/master/redis/client.py#L271 .
One workaround in other forks has been to explicitly pass in a connection-pool object, but this is not optimal in situations like when using pyramid_beaker to set up the session-connection.
This pull request addresses this in a more general way, by internally keeping a dict of ConnectionPool objects, unique by host, port and db. If a new request is made for a redis db we've seen already, the existing ConnectionPool instance will be used.
Adding check for an existing redis-connection as we want to use the c…
…onnection pooling in redis-py which will be put out of play if we keep creating a new StrictRedis object on every request.
Second go at pooling for redis connections.
Further cleanup after code-review.