# HG changeset patch # User Marcin Kuzminski # Date 2019-09-20 17:51:35 # Node ID 4df102562be469ee922cd9ffc236c96c9bf706eb # Parent f5cb74c020adf8a9b2a8498eb0c77804ef6efa0f dogpile: use connection_pool for redis backend which is faster in gevent scenarios diff --git a/rhodecode/lib/rc_cache/backends.py b/rhodecode/lib/rc_cache/backends.py --- a/rhodecode/lib/rc_cache/backends.py +++ b/rhodecode/lib/rc_cache/backends.py @@ -24,6 +24,7 @@ import logging import msgpack import gevent +import redis from dogpile.cache.api import CachedValue from dogpile.cache.backends import memory as memory_backend @@ -203,6 +204,23 @@ class FileNamespaceBackend(PickleSeriali class BaseRedisBackend(redis_backend.RedisBackend): + + def _create_client(self): + args = {} + + if self.url is not None: + args.update(url=self.url) + + else: + args.update( + host=self.host, password=self.password, + port=self.port, db=self.db + ) + + connection_pool = redis.ConnectionPool(**args) + + return redis.StrictRedis(connection_pool=connection_pool) + def list_keys(self, prefix=''): prefix = '{}:{}*'.format(self.key_prefix, prefix) return self.client.keys(prefix)