用python操作redis需要先安装redis的python库,pip install redis,python提供了两种连接redis的方式,一种是直接连接
r = redis.Redis(host='localhost', port= 6379)
另一种方式是使用连接池
pool = redis.ConnectionPool(host='localhost', port=6379)
r = redis.Redis(connection_pool=pool)
r = redis.Redis(host='localhost', port= 6379)
pool = redis.ConnectionPool(host='localhost', port=6379)
r = redis.Redis(connection_pool=pool)