标签:os io 使用 ar for 数据 art div cti
class Redis_Handler(Handler): def connect(self): #print self.host,self.port,self.table self.conn = Connection(self.host,self.port,self.table) def execute(self, action_name): filename = "/tmp/temp.txt" batch_size = 10000 with open(filename) as file: try: count = 0 pipeline_redis = self.conn.client.pipeline() for lines in file: (key,value) = lines.split(',') count = count + 1 if len(key)>0: pipeline_redis.rpush(key,value.strip()) if not count % batch_size: pipeline_redis.execute() count = 0 #send the last batch pipeline_redis.execute() except Exception: print 'redis add error'
标签:os io 使用 ar for 数据 art div cti
原文地址:http://www.cnblogs.com/mfrbuaa/p/3949592.html