##// END OF EJS Templates
dogpile: use connection_pool for redis backend which is faster in gevent scenarios
marcink -
r3930:4df10256 default
parent child Browse files
Show More
@@ -24,6 +24,7 b' import logging'
24
24
25 import msgpack
25 import msgpack
26 import gevent
26 import gevent
27 import redis
27
28
28 from dogpile.cache.api import CachedValue
29 from dogpile.cache.api import CachedValue
29 from dogpile.cache.backends import memory as memory_backend
30 from dogpile.cache.backends import memory as memory_backend
@@ -203,6 +204,23 b' class FileNamespaceBackend(PickleSeriali'
203
204
204
205
205 class BaseRedisBackend(redis_backend.RedisBackend):
206 class BaseRedisBackend(redis_backend.RedisBackend):
207
208 def _create_client(self):
209 args = {}
210
211 if self.url is not None:
212 args.update(url=self.url)
213
214 else:
215 args.update(
216 host=self.host, password=self.password,
217 port=self.port, db=self.db
218 )
219
220 connection_pool = redis.ConnectionPool(**args)
221
222 return redis.StrictRedis(connection_pool=connection_pool)
223
206 def list_keys(self, prefix=''):
224 def list_keys(self, prefix=''):
207 prefix = '{}:{}*'.format(self.key_prefix, prefix)
225 prefix = '{}:{}*'.format(self.key_prefix, prefix)
208 return self.client.keys(prefix)
226 return self.client.keys(prefix)
General Comments 0
You need to be logged in to leave comments. Login now