标签: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()
标签:scl python color import connect class span star div
原文地址:https://www.cnblogs.com/lwhctv/p/10767794.html