创建redis连接池

import redis

def create_redis_pool():
    REDIS_DB = '127.0.0.1'
    REDIS_PORT = 6379
    pool = redis.ConnectionPool(host=REDIS_DB, port=REDIS_PORT, max_connections=1024)
    conn = redis.Redis(connection_pool=pool)
    print('创建redis连接池成功')
    return conn

conn = create_redis_pool()
print(len(conn.smembers('all_urls')))
list1 = [i.decode().split('-')[-1] for i in conn.smembers('all_urls')]
print(list1)
posted @ 2020-11-03 07:52  疯狂列表推导式  阅读(431)  评论(0编辑  收藏  举报