Describe the bug
hset does not support multiple dict mapping.
The code in hset and hmset are exactly same, but it seems hset mapping not working as good as hmset
To reproduce
conn = redis.Redis()
user = {"Name":"Pradeep", "Company":"SCTL", "Address":"Mumbai", "Location":"RCP"}
conn.hset(name = "pythonDict", mapping = user)
conn.hget("pythonDict","Name")
I got this error message
ResponseError Traceback (most recent call last)
in 3 user = {"Name":"Pradeep", "Company":"SCTL", "Address":"Mumbai", "Location":"RCP"} 4 ----> 5 conn.hset(name = "pythonDict", mapping = user) 6 7 conn.hget("pythonDict","Name") ~\miniconda3\lib\site-packages\redis\client.py in hset(self, name, key, value, mapping) 3048 items.extend(pair) 3049 -> 3050 return self.execute_command('HSET', name, *items) 3051 3052 def hsetnx(self, name, key, value):
~\miniconda3\lib\site-packages\redis\client.py in execute_command(self, args, options) 899 try: 900 conn.send_command(args) --> 901 return self.parse_response(conn, command_name, **options) 902 except (ConnectionError, TimeoutError) as e: 903 conn.disconnect()
~\miniconda3\lib\site-packages\redis\client.py in parse_response(self, connection, command_name, **options) 913 "Parses a response from the Redis server" 914 try: --> 915 response = connection.read_response() 916 except ResponseError: 917 if EMPTY_RESPONSE in options:
~\miniconda3\lib\site-packages\redis\connection.py in read_response(self) 754 755 if isinstance(response, ResponseError): --> 756 raise response 757 return response 758
ResponseError: wrong number of arguments for 'hset' command
However, the source code for hset and hmset are same:
Expected behavior
It's expected that hset mapping should behave as same as hmset mapping
Comment From: huangzhw
What is your version of redis. As of Redis 4.0.0, HSET is variadic and allows for multiple field/value pairs.
Comment From: AdriandLiu
@huangzhw Thank you for your response. I am using redis 3.0.504, which is the latest version of https://github.com/microsoftarchive/redis/releases. Is there any newer version for Windows user? Thanks
Comment From: huangzhw
Redis doesn't support Windows. This is a fork of redis and not officially maintained.
Comment From: ptjm
I've only used the redis-cli from this once or twice, but the most up-to-date windows port appears to be:
https://github.com/tporadowski/redis/releases
This is currently at version 5.0.10, which is reasonably fully featured. It doesn't make a lot of sense to use a much older port.
Comment From: AdriandLiu
I've only used the redis-cli from this once or twice, but the most up-to-date windows port appears to be:
https://github.com/tporadowski/redis/releases
This is currently at version 5.0.10, which is reasonably fully featured. It doesn't make a lot of sense to use a much older port.
@ptjm Thank you very much for the helpful info!! Much appreciated!