I am reading Josiah Carlson's Redis in Action.
And in the second chapter there is code like this:
conn.zadd('viewed:' + token, {item: timestamp})
conn.zremrangebyrank('viewed:' + token, 0, -26)
conn.zincrby('viewed:', -1, item) # What is this line doing ?
I just cannot understand what this line trying to do:
conn.zincrby('viewed:', -1, item)
It seems to be creating a member called -1
in the sorted-set(Zset) named viewed:
and incrementing it by the value specified in item
. Assuming item
is numerical. I have no clue why you would want to do this.
Github link to the code is here.
zincrby definition in redis-py.
Am I correct in my intuition ?