Redis py: when to use connection pool?

前端 未结 1 879
你的背包
你的背包 2021-02-14 17:09
pool = redis.ConnectionPool(host=\'10.0.0.1\', port=6379, db=0)
r = redis.Redis(connection_pool=pool)

vs.

r = redis.Redis(host=\'10.0.0         


        
相关标签:
1条回答
  • 2021-02-14 17:56

    From the redis-py docs:

    Behind the scenes, redis-py uses a connection pool to manage connections to a Redis server. By default, each Redis instance you create will in turn create its own connection pool. You can override this behavior and use an existing connection pool by passing an already created connection pool instance to the connection_pool argument of the Redis class. You may choose to do this in order to implement client side sharding or have finer grain control of how connections are managed.

    So, normally this is not something you need to handle yourself, and if you do, then you know!

    0 讨论(0)
提交回复
热议问题