Reputation: 986
I want to test the value of redis can support up to 512MB language:python
import redis
conn = redis.Redis()
temp_dict={}
for i in range(1000000):
temp_dict.update({str(i):str(i)})
conn.hmset('hash-key',temp_dict)
errors: --------------------------------------------------------------------------- ConnectionError Traceback (most recent call last) in () ----> 1 conn.hmset('hash-key',temp_dict)
/usr/local/lib/python2.7/dist-packages/redis/client.pyc in hmset(self, name, mapping)
2009 for pair in iteritems(mapping):
2010 items.extend(pair)
-> 2011 return self.execute_command('HMSET', name, *items)
2012
2013 def hmget(self, name, keys, *args):
/usr/local/lib/python2.7/dist-packages/redis/client.pyc in execute_command(self, *args, **options)
671 if not connection.retry_on_timeout and isinstance(e, TimeoutError):
672 raise
--> 673 connection.send_command(*args)
674 return self.parse_response(connection, command_name, **options)
675 finally:
/usr/local/lib/python2.7/dist-packages/redis/connection.pyc in send_command(self, *args)
608 def send_command(self, *args):
609 "Pack and send a command to the Redis server"
--> 610 self.send_packed_command(self.pack_command(*args))
611
612 def can_read(self, timeout=0):
/usr/local/lib/python2.7/dist-packages/redis/connection.pyc in send_packed_command(self, command)
601 errmsg = e.args[1]
602 raise ConnectionError("Error %s while writing to socket. %s." %
--> 603 (errno, errmsg))
604 except:
605 self.disconnect()
ConnectionError: Error 104 while writing to socket. Connection reset by peer.
Upvotes: 1
Views: 2524
Reputation: 11
Maybe the data inserted at one time is too large, and the data can be separated and only 100000 pieces can be hmset at a time。
import redis
conn = redis.Redis()
for x in range(10):
temp_dict={}
for i in range(100000):
temp_dict.update({str(i):str(i)})
conn.hmset('hash-key',temp_dict)
Upvotes: 1