码迷,mamicode.com
首页 > 编程语言 > 详细

Python-rediscluster客户端

时间:2019-04-25 13:16:01      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:scl   python   color   import   connect   class   span   star   div   

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import redis
from rediscluster import StrictRedisCluster
import sys

#pip install redis-py-cluster
def redis_cluster():
    redis_nodes = [
        {host: 10.32.114.34, port: 6404},
        {host: 10.32.106.42, port: 6402},
        {host: 10.32.104.37, port: 6406},
        {host: 10.32.114.34, port: 6407},
        {host: 10.32.104.37, port: 6400},
        {host: 10.32.106.42, port: 6409},
        {host: 10.32.106.42, port: 6408},
        {host: 10.32.114.34, port: 6409},
        {host: 10.32.114.34, port: 6408},
        {host: 10.32.106.42, port: 6407},
        {host: 10.32.104.37, port: 6401},
    ]
    try:
        redissconn = StrictRedisCluster(startup_nodes=redis_nodes)
    except Exception as e:
        print
        Connect Error!
        sys.exit(1)
    for i in range(100000):
        key = foo_%d % i
        redissconn.set(key,i)
        if i % 100 == 0:
            print (key)

redis_cluster()

 

Python-rediscluster客户端

标签:scl   python   color   import   connect   class   span   star   div   

原文地址:https://www.cnblogs.com/lwhctv/p/10767794.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!