If every value one adds to a sorted set (redis) is one with the highest score, will the time complexity be O(log(N))
for each zadd
?
OR, for such edge cases, redis performs optimizations (e.g. an exception that in such cases where score
is higher than the highest score
in the set, simply add the value at the highest spot)?
Practically, I ask because I keep a global sorted set in my app where values are zadded
with time since epoch as the score. And I'm wondering whether this will still be O(log(N))
, or would it be faster?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…