Implementing ZADD If Key Exists
I recently had to make some performance optimizations. These are my favorite kind of coding task as they usually require some sort of creativity and tradeoff. This time around I also learned more about Redis and practiced using AI to generate code.
During my refactor, I came across a need to upsert a (member, score) into a Redis sorted set only if the Redis sorted set exists. This upsert would be done hundreds of times a second for different keys, so it had to be fast.
The basic ZADD command offers a XX flag which adds a (member, score) only if the member exists in the sorted set. Bu...
评论
?
参与讨论