0

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?

2 Answers 2

11
hash = 'list:123'
key = 'count'
n = 1

r.hincrby(hash, key, n)
Sign up to request clarification or add additional context in comments.

Comments

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

Use this page for reference

https://redis.io/commands/hincrby

1 Comment

I think the point is not to overwrite what's already there. More of a read+write op, like hincrby.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.