I have created a hash
in redis in python as follows:
r.hmset('list:123', {'name': 'john', 'count': 5})
How can I increment the value of count for the key list:123
?
hash = 'list:123'
key = 'count'
n = 1
r.hincrby(hash, key, n)
I haven't tested this, but from the docs it looks like it will do the job.
r.hmset('list:123', {'name': 'john', 'count': 5})
d = r.hgetall('list:123')
d.count += 1
r.hmset('list:123', d)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.