didip/beaker_extensions — pull request #17 by zwant (2013-03-01 16:13:41+00:00)
Title: Redis connection pooling

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 existing StrictRedis objects, unique by host, port and db. If a new request is made for a redis db we've seen already, the existing StrictRedis instance will be used and thus also triggering the built-in connection pooling.