python获取所有数据,获取redis库中所有键值对
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import redis pool = redis.ConnectionPool(host='127.0.0.1', port=6379, db=0) r = redis.Redis(connection_pool=pool) len = 0 key_list = [] print r.pipeline() keys = r.keys() for key in keys: key_list.append(key) pipe.get(key) if len < pipe_size: len += 1 else: for (k, v) in zip(key_list, pipe.execute()): print k, v len = 0 key_list = [] for (k, v) in zip(key_list, pipe.execute()): print k, v |