##// END OF EJS Templates
caches: added redis pool for redis cache backend
marcink -
r781:9979cb94 default
parent child
Show More
@@ -20,6 +20,8 import errno
20 import logging
20 import logging
21
21
22 import msgpack
22 import msgpack
23 import redis
24
23 from dogpile.cache.api import CachedValue
25 from dogpile.cache.api import CachedValue
24 from dogpile.cache.backends import memory as memory_backend
26 from dogpile.cache.backends import memory as memory_backend
25 from dogpile.cache.backends import file as file_backend
27 from dogpile.cache.backends import file as file_backend
@@ -124,6 +126,9 class FileNamespaceBackend(PickleSeriali
124 arguments['lock_factory'] = CustomLockFactory
126 arguments['lock_factory'] = CustomLockFactory
125 super(FileNamespaceBackend, self).__init__(arguments)
127 super(FileNamespaceBackend, self).__init__(arguments)
126
128
129 def __repr__(self):
130 return '{} `{}`'.format(self.__class__, self.filename)
131
127 def list_keys(self, prefix=''):
132 def list_keys(self, prefix=''):
128 prefix = '{}:{}'.format(self.key_prefix, prefix)
133 prefix = '{}:{}'.format(self.key_prefix, prefix)
129
134
@@ -167,6 +172,23 class FileNamespaceBackend(PickleSeriali
167
172
168
173
169 class BaseRedisBackend(redis_backend.RedisBackend):
174 class BaseRedisBackend(redis_backend.RedisBackend):
175
176 def _create_client(self):
177 args = {}
178
179 if self.url is not None:
180 args.update(url=self.url)
181
182 else:
183 args.update(
184 host=self.host, password=self.password,
185 port=self.port, db=self.db
186 )
187
188 connection_pool = redis.ConnectionPool(**args)
189
190 return redis.StrictRedis(connection_pool=connection_pool)
191
170 def list_keys(self, prefix=''):
192 def list_keys(self, prefix=''):
171 prefix = '{}:{}*'.format(self.key_prefix, prefix)
193 prefix = '{}:{}*'.format(self.key_prefix, prefix)
172 return self.client.keys(prefix)
194 return self.client.keys(prefix)
General Comments 0
You need to be logged in to leave comments. Login now