Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Connection Pool in redis python client redis-py
import redis
class RedisStorage(object):
_redis_pool = {}
@classmethod
def setup_redis_pool(cls, redis_pool):
for k, v in redis_pool.iteritems():
cls._redis_pool[k] = redis.Redis(v[0], v[1])
def _get_db(self, db_name):
return self._redis_pool.get(db_name, None)
class CommentRedis(RedisStorage):
def add_comment(self, checkin_id, comment_id, comment_data):
r_client = self._get_db("COMMENT")
# u can use redis now
@gradetwo
Copy link
Author

gradetwo commented Jul 10, 2013

remember call setup_redis_pool when app init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment