ZADD key score member
Add the specified member having the specified score to the sorted set stored at the key.
Note:
1. If a member is already a member of the sorted set the score is updated, and the element is reinserted in the right position to ensure sorting.
2. If the key does not exist a new sorted set with the specified member as a sole member is created.
3. If the key exists but does not hold a sorted set value an error is returned.
TIME COMPLEXITY: O(log(N)) with N being the number of elements in the sorted set
The score value can be the string representation of a double precision floating point number.
RETURN VALUE: Integer reply, specifically:
1 if the new element was added
0 if the element was already a member of the sorted set and the score was updated.
Syntax:
ZADD key score member
Example 1: When the score is a valid float value.
redis:6379> ZADD key 10.9 member(integer) 1
Output
1
Example 2: When the score is not a valid float value.
redis:6379> ZADD key score member(error) value is not a valid float
Output
(error) value is not a valid float
No comments:
Post a Comment