Search code examples
pythonredisredis-py

Increment value of a hash field in Redis using Python


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?


Solution

  • r.hincrby("list:123", "count", 1)
    

    Use this page for reference

    https://redis.io/commands/hincrby